[R] var[i]

juli g. pausas juli at ceam.es
Thu May 1 19:03:11 CEST 2003


Dear all,
How could I use variables in a loop that their names are in a vector? 
For example:

aaa <- 1:10
bbb <- aaa*2
ccc <- aaa+bbb

varn <- c("aaa", "bbb", "ccc")
m <- rep(NA, 3)

for (i in 1:length(varn)) m[i] <- mean(varn[i])  # wrong


thanks in advance

Juli



--
"Wars do not solve problems, wars generate even more problems"



More information about the R-help mailing list