[R] list of all objects - just being curious

Kaspar Pflugshaupt pflugshaupt at geobot.umnw.ethz.ch
Thu Sep 27 19:18:42 CEST 2001

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

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