[R] list structure question

Gabor Grothendieck ggrothendieck at myway.com
Thu Jul 1 17:59:40 CEST 2004

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)



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?

More information about the R-help mailing list