[R] list of all objects - just being curious

Liaw, Andy andy_liaw at merck.com
Thu Sep 27 20:10:10 CEST 2001


The culprit (?) seems to be the line

   name <- substitute(name)

in ls().  I tried ls(search()[1]).  Inside ls(), name has the correct value
of ".GlobalEnv" before this line, but after the substitution it becomes
search()[1], which confuses the pos.to.env() call.

I'm not sure what would break w/o that line.  Any one know how to solve
this?

Andy

> -----Original Message-----
> From: Kaspar Pflugshaupt [mailto:pflugshaupt at geobot.umnw.ethz.ch]
> Sent: Thursday, September 27, 2001 1:19 PM
> To: r-help
> Subject: [R] list of all objects - just being curious
> 
> 
> Hello all,
> 
> to obtain a list of all objects in all search paths, I've found the
> following to work:
> 
> > biglist <- sapply(1:length(search()), objects)
> 
> This more obvious one, however, does not work:
> 
> > biglist <- sapply(search(), objects)
> Error in pos.to.env(pos) : invalid argument
> 
> Still, search() gives
> 
> [1] ".GlobalEnv"    "package:ctest" "Autoloads"     "package:base"
> 
> and objects(".GlobalEnv"), objects("package:ctest") etc. all 
> give their
> respective vectors. So why does the sapply() construction not 
> work here?
> 
> I've also tried a for() loop ("for (I in search()) 
> print(objects(I))") with
> the same error message. Again, "for (I in 1:length(search()))
> print(objects(I))" works all right.
> 
> What am I misunderstanding?
> 
> 
> Kaspar Pflugshaupt
> 
> (R 1.3.1 on MacOS 9.2)
> 
> -- 
> 
> Kaspar Pflugshaupt
> Geobotanisches Institut
> Zuerichbergstr. 38
> CH-8044 Zuerich
> 
> Tel. ++41 1 632 43 19
> Fax  ++41 1 632 12 15
> 
> mailto:pflugshaupt at geobot.umnw.ethz.ch
> privat:pflugshaupt at mails.ch
> http://www.geobot.umnw.ethz.ch
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -.-.-.-.-.-.-.-.-
> r-help mailing list -- Read 
> http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: 
> r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> _._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list