Good evening Allan,
I bet what you want is
SomeFunction(g[[i]][names(g[[i]])="varname"])
Kentaro
----- Original Message -----
From: "Allan Friedman" <allan.friedman(a)gmail.com>
To: <gov2001-l(a)lists.fas.harvard.edu>
Sent: Sunday, December 19, 2004 1:35 PM
Subject: [gov2001-l] dynamic variable names in R?
Suppose I have several dataframes: g1, g2, g3....
Each as the same variable names: X, Y....
I want to write a function that can deal with variables across the
dataframes. The easiest way that I can think of to do it would be to
write a function that could walk through each dataframe and do stuff
to the variables, something like:
mush.data <- function(varname, numgroups) {
for(i in 1:numgroups) {
SomeFunction(paste("g", i, "$",varname)
}
BUT - paste just gives me a string. How do I get R to realize that
it's actually pointing to a vector? I feel that R should let me do
this, right?
Any help would be greatly appreciated.
/\llan
_______________________________________________
gov2001-l mailing list
gov2001-l(a)lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l