[R] evaluating and walking in names
Cezar Augusto de Freitas Anselmo
cafa at ime.unicamp.br
Wed Aug 6 22:24:02 CEST 2003
Hi, all.
Suppose I have an object with names (like a data.frame) and I want to walk
in a loop with your names. How can I do this? The idea is like this:
my.data<-data.frame(matrix(runif(6),ncol=2))
names(my.data)
[1] "X1" "X2"
for(i in names(my.data)){
my.variable <- cat(paste("my.data$", i, "\n", sep=""))
print(mean(my.variable))
}
#it doesn't work.
Thnaks for all,
C.
========================================
Cezar Freitas (ICQ 109128967)
IMECC - UNICAMP
Campinas, SP - Brasil
More information about the R-help
mailing list