[R] Which "apply" function to use?

Masca, N. nm180 at leicester.ac.uk
Mon Sep 14 18:22:26 CEST 2009


Dear All,

I have a problem which *should* be pretty straightforward to resolve - but I can't work out how!

I have a list of 3 coefficient estimates for 4 different datasets:

Coefs<-list(c(1,0.6,0.5),c(0.98,0.65,0.4),c(1.05,0.55,0.45),c(0.99,0.50,0.47))

All I want to do is take the sum (or mean) of each coefficient across the 4 datasets.  

I can do this using a "for" loop, but it gets very messy - as I need to do this several times I was hoping someone might have a better solution using one of the "apply" functions.  Any ideas?

Many thanks for any help you can provide.

Cheers,

Nick




More information about the R-help mailing list