[R] Flexibly Retrieving Objects with an Index

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


That works great.  Thanks, Henrique.  -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

On Feb 2 2011, Henrique Dallazuanna wrote:

>Try this:
>
>do.call(rbind, mget(ls(pattern = 'data'), envir = .GlobalEnv))
>
 On Wed, Feb 2, 2011 at 5:20 PM, Christopher T. Moore 
<moor0554 at umn.edu>wrote:
>
>> 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 <http://umn.edu/%7Emoor0554>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
>



More information about the R-help mailing list