Possible Duplicate:
Identify all objects of given class for further processing
I want to build an index of every data frame I have in my workspace. How do I write something sounding like:
dindex <- ls(class=data.frame)
Possible Duplicate:
Identify all objects of given class for further processing
I want to build an index of every data frame I have in my workspace. How do I write something sounding like:
dindex <- ls(class=data.frame)
Based on the link @Chase provided in the comments, you can Filter
the results of ls
to only include the names of objects that inherit
the data.frame
class.
#R --vanilla -q
a <- data.frame(1:3)
b <- data.frame(1:2, 4:3)
L <- list(a, b)
Filter(function(x) inherits(get(x), "data.frame"), ls())
#[1] "a" "b"