1

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)
Community
  • 1
  • 1
dmvianna
  • 15,088
  • 18
  • 77
  • 106
  • have you seen [`.ls.objects`](http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session)? – GSee Aug 29 '12 at 02:38
  • this question is related: http://stackoverflow.com/questions/5158830/identify-all-objects-of-given-class-for-further-processing – Chase Aug 29 '12 at 02:49
  • Actually, I need more help here. .ls.objects lists modes, but does not restrict results to a 'mode' argument. – dmvianna Aug 29 '12 at 03:20

1 Answers1

4

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"
GSee
  • 48,880
  • 13
  • 125
  • 145