[R] What command lists everything in a package?

Duncan Murdoch murdoch at stats.uwo.ca
Fri Jul 3 19:35:24 CEST 2009


On 7/3/2009 1:21 PM, Mark Knecht wrote:
> Hi,
>    Two easy questions I'm sure.
> 
> 1) As an example if I use the code
> 
> require(zoo)
> 
> then once it's loaded is there a command that lists everything that
> zoo provides so that I can study the package?

ls("package:zoo") will list all the exported items in zoo, provided it 
is attached. You can abbreviate that to the number in the search list, 
which is usually 2 immediately after you attach the package.  So

require(zoo)
ls(2)

will probably do what you want.  Use search() to see the search list.

Duncan Murdoch

> 
>    Certainly help(zoo) gives me some clues about what zoo does but I'd
> like a list. Maybe there's a way to query something but in Rgui under
> Win Vista ls() returns nothing after zoo is loaded.
> 
> 2) Related to the above, how do I tell what packages are currently
> loaded at any given time so that I don't waste time loading things
> that are already loaded? search() tells me what's available, but
> what's loaded? The best I can find so far goes like this:
> 
>> a<-.packages(all.available = FALSE)
>> a
> [1] "zoo"       "stats"     "graphics"  "grDevices" "utils"     "datasets"
> [7] "methods"   "base"
>>
> 
> Maybe that's as good as it gets in code and if I want better then I
> write a function?
> 
> Thanks,
> Mark
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list