"Prof Brian Ripley" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> 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.

Reply via email to