[R] Reference variables by string in for loop
Michael Bach
phaebz at gmail.com
Fri Apr 29 12:03:06 CEST 2011
Dear R Users,
I am trying to get the following to work better:
namevec <- c("one", "two", "three")
for (name in namevec) {
namedf <- eval(parse(text=paste(name, "_df", sep="")))
...
...
}
The rationale behind it being that I created variables with names
one_df, two_df and three_df earlier in the same script which I want to
reference inside the for loop. Is there a more elegant way to do this?
Best Regards,
Michael Bach
More information about the R-help
mailing list