s-news
[Top] [All Lists]

lapply question

To: s-news@lists.biostat.wustl.edu
Subject: lapply question
From: Dave Evens <devens8765@yahoo.com>
Date: Tue, 19 Jul 2005 06:35: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=S1qS7smdrRpzcqYsqwOWJD9GXQQYiAfNOYcQNv5gjMlcM2QvNlYh+bt5LqQuLfqGRmnPdPID5RI/W3mr4RDJ5MBxmQbm5PXPN/NYbGG2b4ABNtPFroT1wsh2cG2eKVrY6taoQmVpuPn7BHUXHroAuunNpOygRKWQylAbX2FPo7E= ;
Dear members,

I have numerous arrays that are organised in a list.
For example, suppose I have 2 arrays in a list called
alist

alist <- list(array(rpois(12,5), 6:8)
, array(rpois(15,5), 10:12))

with array dimnames

dimnames(alist[[1]]) <- list(LETTERS[1:6],
paste("namesd", 1:7, sep=""), paste("namese", 1:8,
sep=""))
dimnames(alist[[2]]) <- list(LETTERS[7:16],
paste("namesf", 1:11, sep=""), paste("namesg", 1:12,
sep=""))

My first question is: is it possible to name the
arrays themselves, e.g. if I try

names(alist) <- list("Array 1", "Array 2")

I get "\" and \"" at the beginning and end of each
name, i.e. 

[1] "\"Array 1\"" "\"Array 2\""

Secondly, I would like to use the lapply function to
produce a report with:

____________________________________________________
Array 1 

Dimension name: namese1

Row  Value              Value-Average(excluding Value)
 A   alist[[1]][1,1,1] 
alist[[1]][1,1,1]-mean(alist[[1]][1,-1,1])

...etc for all elements in the first row on the array

 B   alist[[1]][2,1,1] 
alist[[1]][2,1,1]-mean(alist[[1]][2,-1,1])

...etc

Dimension name: namese2
....
Dimension name: namese8
A...

Array 2

Dimension name: namesg1

...

Dimension name: namesg12
...

______________________
Can I use the apply to do this, something like

lapply(alist, function(k), apply(k, c(1,3), ...

but how do I layout the report using the array names,
dimension names etc and with each observation on a
separate line? Is this possible?

Thanks for any help in advance.

Dave











                
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

<Prev in Thread] Current Thread [Next in Thread>