I know you already got a good answer from Joshua Wiley.
Here is a function I find useful.
Anyone who wants to suggest improvements, please do so!

> my.ls
function(pos=1, sorted=FALSE, mode, class){
   .result <- sapply(ls(pos=pos, all.names=TRUE),
       function(..x)object.size(eval(as.symbol(..x))))
   if (sorted){
       .result <- rev(sort(.result))
   }
   .ls <- as.data.frame(rbind(as.matrix(.result),"**Total"=sum(.result)))
   names(.ls) <- "Size"
   .ls$Size <- formatC(.ls$Size, big.mark=',', digits=0, format='f')
   .ls$Mode <- c(unlist(lapply(rownames(.ls)[-nrow(.ls)],
       function(x)base::mode(eval(as.symbol(x))))), '-------')
   if (!missing(mode)) {
      .ls <- .ls[sapply(.ls$Mode, function(x) any(unlist(strsplit(x, ", "))  
%in% mode)), , drop=FALSE]
   }
   .ls$Class <- c(sapply(rownames(.ls)[-nrow(.ls)],
       function(x) paste(unlist(base::class(eval(as.symbol(x)))), collapse=", 
")), '-------')
   if (!missing(class)) {
      .ls <- .ls[sapply(.ls$Class, function(x) any(unlist(strsplit(x, ", "))  
%in% class)), , drop=FALSE]
   }
   .ls
}

So:
> my.ls(class='data.frame')
         Size Mode      Class
df      1,320 list data.frame
DF        648 list data.frame
DF2       712 list data.frame
geu1   72,864 list data.frame
result  1,384 list data.frame
t         896 list data.frame

HTH,
-- David L. Reiner


-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Erin Hodgess
Sent: Saturday, October 01, 2011 10:38 PM
To: R help
Subject: [R] getting list of data.frame names

Dear R People:

This is probably a very simple question.  I know that if I want to get a list 
of the classes of the objects in the workspace, I can do this:

> sapply(ls(), function(x)class(get(x)))
           a        a1.df            b            d
      "list" "data.frame"    "integer"    "numeric"

Now I want to get just the data frames.
> sapply(ls(), function(x)class(get(x))=="data.frame")
    a a1.df     b     d
FALSE  TRUE FALSE FALSE

However, I would like the names of the data frames, rather than the True/False 
for the objects.

I've been trying all sorts of combinations/permutations with no success.

Any suggestions would be much appreciated.

Thanks,
Sincerely,
Erin



--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences University of Houston - 
Downtown
mailto: erinm.hodg...@gmail.com

______________________________________________
R-help@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.


This e-mail and any materials attached hereto, including, without limitation, 
all content hereof and thereof (collectively, "XR Content") are confidential 
and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are 
protected by intellectual property laws.  Without the prior written consent of 
XR, the XR Content may not (i) be disclosed to any third party or (ii) be 
reproduced or otherwise used by anyone other than current employees of XR or 
its affiliates, on behalf of XR or its affiliates.

THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY 
KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY 
DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR 
CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE 
FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, 
DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS 
AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR 
INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF 
SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.

______________________________________________
R-help@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.

Reply via email to