Hi,

you could try the reshape package,

l = list(d1= data.frame(ID=letters[1:4],value=1:4),
          d2= data.frame(ID=letters[1:4],value= -c(1:4)))

library(reshape)
m = melt(l)

cast(m, .~ID, fun=mean)

HTH,

baptiste

2009/7/15 Mark Na <[email protected]>

> Dear R-helpers,
> I have a list containing 5000 elements, each element is a dataframe
> containing one ID column (identical over the 5000 dataframes) and 9 numeric
> variables, e.g.
>
> ID VAR1 VAR2 VAR3 ... VAR9
>
> I would like to create a new dataframe containing the ID column and the
> mean
> values of the 9 numeric variables. So, the structure of this new dataframe
> would be identical to the structure of the dataframes stored in my list
> (and
> the ID column would also be identical) but the values would be mean values.
>
> I've been attempting to do this with rowMeans and subscripting the list
> using double square brackets, but I can't get it to work.
>
> I'd appreciate any pointers to get me going, thanks!
>
> Mark Na
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

_____________________________

Baptiste AuguiƩ

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to