[R] Flexibly Retrieving Objects with an Index

Christopher T. Moore moor0554 at umn.edu
Wed Feb 2 20:20:05 CET 2011


Greetings,

I would like to flexibly combine several data frames objects without 
specifying the exact names of the objects in memory. Should I use indexing 
to call those objects out of memory? I regularly use indexes to flexibly 
extract parts of data frames and lists and to read files from my hard 
drive, but I can't figure out how to do so with stored objects.

In my case, all of the data frames of interest are formatted the same way 
and have been assigned to objects with the prefix "data.". The following 
examples combine only the names (not the objects themselves):
rbind(ls()[grep("data.", ls(), fixed=T)])
list(ls()[grep("data.", ls(), fixed=T)])

Is there a way to get ls() (or some other function) to return the object 
instead of just the name? I searched the help files and the R-help archives 
but couldn't find a solution. Thanks in advance.

Sincerely,
Chris

-- 
Christopher T. Moore, M.P.P.
Doctoral Student
Quantitative Methods in Education
University of Minnesota
44.9785°N, 93.2396°W
moor0554 at umn.edu
http://umn.edu/~moor0554



More information about the R-help mailing list