From: Gabor Grothendieck <ggrothendieck_at_myway.com>

Date: Fri 02 Jul 2004 - 01:59:40 EST

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 02 02:03:28 2004

Date: Fri 02 Jul 2004 - 01:59:40 EST

Here are three solutions but I think the original idea of just converting to a data frame and using rowMeans (last solution) is simplest:

L <- list(1:5, 6:10) # test list

do.call("mapply", c(sum,L)) / length(L)

sapply(seq(along=L),function(i)mean(sapply(L,"[[",i)))

rowMeans(as.data.frame(L))

Rajarshi Guha <rxg218 <at> psu.edu> writes:

*:
**: Hi,
*

: I have a list in which element is a vector (all of the same length and

*: all numeric). I want to find the mean of the first elements of the
**: vectors, the mean of the second elements of the vectors and so on.
**:
**: Currently I convert the list to a data.frame and apply rowMeans(). But
**: is there a way to to do this directly on the list? I seem to recall a
**: post in which there was such a function (or expression) but I just cant
**: seem to find it.
**:
**: Could somebody point me in the right direction?
*

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 02 02:03:28 2004

*
This archive was generated by hypermail 2.1.8
: Wed 03 Nov 2004 - 22:54:38 EST
*