Re: [R] listing all functions in R

From: Earl F. Glynn <efg_at_stowers-institute.org>
Date: Mon 08 Jan 2007 - 20:20:09 GMT

"Prof Brian Ripley" <ripley@stats.ox.ac.uk> wrote in message news:Pine.LNX.4.64.0701061331420.8651@gannet.stats.ox.ac.uk...
> Here is a reasonable shot:
>
> findfuns <- function(x) {
> if(require(x, character.only=TRUE)) {
> env <- paste("package", x, sep=":")
> nm <- ls(env, all=TRUE)
> nm[unlist(lapply(nm, function(n) exists(n, where=env,
> mode="function",
> inherits=FALSE)))]
> } else character(0)
> }
> pkgs <- dir(.Library)
> z <- lapply(pkgs, findfuns)
> names(z) <- pkgs

Any recommendations on how to trap problems with "require" when using findfuns? One bad package and the lapply above doesn't return anything.

For example:

> findfuns("bcp")

Loading required package: bcp
Loading required package: DNAcopy
Error: package 'DNAcopy' could not be loaded In addition: Warning message:
there is no package called 'DNAcopy' in: library(pkg, character.only = TRUE, logical = TRUE, lib.loc = lib.loc)

> require("bcp", character.only=TRUE)

Loading required package: bcp
Loading required package: DNAcopy
Error: package 'DNAcopy' could not be loaded In addition: Warning message:
there is no package called 'DNAcopy' in: library(pkg, character.only = TRUE, logical = TRUE, lib.loc = lib.loc)

I used "try" around the "require" call with "options(error=recover)" with "recover" defined to be a do nothing function to avoid the stop, but then there were other problems (e.g., "unable to load shared library ... LoadLibrary Failure: The specified module could not be found" and "Maximal number of DLLs reached")

Besides "bcp" I saw problems with other packages, e.g., cairoDevice, caMassClass, ... several others.

I'm using R 2.4.1with all CRAN packages installed that existed last week and at least several Bioconductor packages installed by the biocLite procedure.

FWIW:
> length(pkgs)

[1] 957

Thanks for any suggestions.

efg

Earl F. Glynn
Scientific Programmer
Stower Institute



R-help@stat.math.ethz.ch 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. Received on Tue Jan 09 08:23:59 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 Jan 2007 - 21:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.