Re: [R] lapply to subsets

2010-10-12 Thread Feng Li
Yes, that is what I what... Thanks. Feng On Wed, Oct 13, 2010 at 6:38 AM, Michael Bedward wrote: > Hello Feng, > > I think you just want this... > > lapply(A, function(x) apply(x[,,-c(1,2)], c(1,2), mean)) > > Michael > > > On 13 October 2010 04:00, Feng Li wrote: > > Dear R, > > > > I have a s

Re: [R] lapply to subsets

2010-10-12 Thread Michael Bedward
Hello Feng, I think you just want this... lapply(A, function(x) apply(x[,,-c(1,2)], c(1,2), mean)) Michael On 13 October 2010 04:00, Feng Li wrote: > Dear R, > > I have a silly question concerns with *apply. Say I have a list called A, > > A <- list(a  =  array(1:20, c(2, 2, 5)), b  = array(1

[R] lapply to subsets

2010-10-12 Thread Feng Li
Dear R, I have a silly question concerns with *apply. Say I have a list called A, A <- list(a = array(1:20, c(2, 2, 5)), b = array(1:30, c(2, 3, 5))) I wish to calculate the mean of A$a, and A$b w.r.t. their third dimension so I did lapply(A,apply,c(1,2),mean) Now if I still wish to do the