s-news
[Top] [All Lists]

apply question

To: s-news@lists.biostat.wustl.edu
Subject: apply question
From: Dave Evens <devens8765@yahoo.com>
Date: Mon, 19 Sep 2005 08:01:26 -0700 (PDT)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ZtZkopkmjgyDpTmI+YDpyv2Z5Ak2cZqWik2VEC7WKC2/QNLCjetzoabg6WBjRT5tJN4VWIExPjhgZvg/cZPbp1/6y46GtOQ0scRW9Y8OVwkDjVy+oHn3UVm5aEeH5tppAqqQRTlHGTgVN4FCZ2H8BfURK/UGR45U13pysxrdQxI= ;

Dear all,

I have a list of arrays and I would like to produce a
list of all the values in the arrays along with the
names of the values and the other dimension names. For
example, I have arrays

my.arrays <- list(array(rnorm(720, 10, 2), 8:10),
array(rnorm(336, 20, 6), 6:8), array(rnorm(120, 7, 1),
4:6))

with dimension names

dimnames(my.arrays[[1]]) <- list(LETTERS[1:8],
LETTERS[6:14], LETTERS[17:26]) 
dimnames(my.arrays[[2]]) <- list(LETTERS[1:6],
LETTERS[7:13], LETTERS[14:21])                  
dimnames(my.arrays[[3]]) <- list(LETTERS[5:8],
LETTERS[10:14], LETTERS[16:21])


I can produce a list of all the values, values- column
mean and the name of the value, i.e.
unlist(lapply(seq(length(my.arrays)), function(k,
my.arrays) {apply(my.arrays[[k]], c(2,3), function(x)
{
                        x.mean <- mean(x)
                        cbind(paste(round(x,3), round(x-x.mean,3),
names(x)))
                })
}, my.arrays))


What I would like is the names of the other two
dimensions in the list, e.g. first component

 "11.713 0.984 A  F  Q"  instead of 
 "11.713 0.984 A"

Is this possible using the apply command as it doesn't
track the indices of the other dimensions?

Thanks in advance for any help.

Dave



                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

<Prev in Thread] Current Thread [Next in Thread>
  • apply question, Dave Evens <=