[R] ls() and classes

David Winsemius dwinsemius at comcast.net
Wed Mar 19 15:50:32 CET 2008


Rolf Turner <r.turner at auckland.ac.nz> wrote in
news:72856D72-D960-48ED-AA77-ABD353548C08 at auckland.ac.nz: 

> 
> On 19/03/2008, at 4:39 PM, Erin Hodgess wrote:
> 
>> Dear R People:
>>
>> I want to get the class of all of the objects in my directory.
>>

> 
> Too easy!!!
> 
> sapply(ls(),function(x){class(get(x))})
> 


Thank you, Rolf. That supplied the needed index to the question I 
struggled with yesterday: How to get a list of only my dataframes:

ls()[sapply(ls(),function(x){class(get(x))}) == "data.frame"]

-- 
David Winsemius



More information about the R-help mailing list