[R] Summing x1 to x6

Pablo pschatfield at gmail.com
Tue Dec 20 09:10:58 CET 2011


Thank you guys for your suggestions!  Florent D - that probably is the way of
writing what I had in my head.  The suggestion I took up was one of
JHoltman's which he put in an e-mail to me following his initial post but it
works well with the vectors in this question:

require(plyr)
x1.6 <- laply(1:6, function(a) get(paste('x', a, sep = '')))
rowMeans(x1.6)

It is nice because it's easily extendable to matrices too which I want to do
later - change rowMeans(x1.6) to colMeans(x1.6).

Thank you all for your help,

Pablo

--
View this message in context: http://r.789695.n4.nabble.com/Summing-x1-to-x6-tp4214604p4216977.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list