[S] Re: objects() and ls()

Richard M. Heiberger (rmh@fisher.stat.temple.edu)
Tue, 27 Oct 1998 23:04:16 -0500


Inspired by John Wallace and Nick Ellis, I updated a function I wrote
years ago that is functionally similar to the undocumented find.objects.
I believe my formatting is easier to read than find.objects because I use
a named list. The name is that of the the database, and the objects in each
item of the list are the names of the appropriate objects in the database.

I call it objip, as in objects(i, pattern=""), because is loops through
the search() list and the frames. The same function works in both
4.x for Windows and 3.4 for unix because the wild cards are added by the
function if it discovers it is running under the i386 architecture.

Sample usage is
objip("obj")
to find all objects in all attached databases that have the pattern "obj".
The optional where argument can limit it to a subset of the search() list.
The optional frame argument can include frames.

objip <-
function(pattern, where=search(), frame=NULL)
{
###Richard M. Heiberger, October 1998.
result <- list()
if (version$arch == "i386") pattern <- paste("*", pattern, "*", sep = "")
for(i in where) {
obj <- objects(i, p = pattern)
if(length(obj) > 0) result[[i]] <- obj
}
for(i in frame) {
obj <- objects(frame=i, p = pattern)
if(length(obj) > 0) result[[paste("Frame",i,sep=".")]] <- obj
}
result
}
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news