[R] lapply to subsets
michael.bedward at gmail.com
Wed Oct 13 06:38:55 CEST 2010
I think you just want this...
lapply(A, function(x) apply(x[,,-c(1,2)], c(1,2), mean))
On 13 October 2010 04:00, Feng Li <feng.li at stat.su.se> 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: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
> Now if I still wish to do the above task but take away some burn-in, e.g. do
> not take A$a[,,1:2],and A$b[,,1:2] into account. How can I do then?
> Feng Li
> Department of Statistics
> Stockholm University
> 106 91 Stockholm, Sweden
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help