[R] lapply question

From: Dave Evens <devens8765_at_yahoo.com>
Date: Wed 20 Jul 2005 - 19:57:35 EST


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=""))

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
...

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 it possible to give apply an array and output a list?

Thanks for any help in advance.

Dave



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 20 20:05:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:51 EST