[R] listing all functions in R

Earl F. Glynn efg at stowers-institute.org
Tue Jan 9 23:51:05 CET 2007


"Seth Falcon" <sfalcon at fhcrc.org> wrote in message 
news:m23b6k5idc.fsf at fhcrc.org...
> Are you sure you need to?  I just tried your code above with:
>
> pkgs <- c("Biobase", "GOstats", "flrblr", "bazbaz")
>
> And while I see warning messages about the flrblr and bazbaz packages,
> the function completed and I get the expected results in z.
>
> Oh, perhaps you have some broken installs?  Broken in the sense that
> you have a package installed but not its dependencies?

I installed all known CRAN packages after installing R 2.4.1 last week on a 
PC.  Perhaps some new consistency checks checks could be be made to catch 
such dependency problems?

>
> How about this:
>
> safeRequire <- function(x) {
>    tryCatch(require(x, character.only=TRUE),
>             error=function(e) FALSE)
> }

Thanks.  That's a much better function.

But if your process a lot of packages, even with just safeRequire (or 
findfuns), the search() path grows quite long, and things break, so it's not 
really possible to get a list of all functions in R if you have all packages 
installed.

Consider:

pkgs <- dir(.Library)

length(pkgs)        #957

length( search() )  # 9

# First 100 Packages
set1 <- lapply(pkgs[1:100], safeRequire)
pkgs[which(!unlist(set1))]
#[1] "bcp"         "cairoDevice" "caMassClass"
length( search() )  # 135

safeRequire("bcp")

####################################
Loading required package: bcp
Loading required package: DNAcopy
Warning in library(pkg, character.only = TRUE, logical = TRUE, lib.loc = 
lib.loc) :
         there is no package called 'DNAcopy'
[1] FALSE
####################################


In the 2nd 100 many packages seem to be affected by the "Maximal number of 
DLLs reached..."

I didn't bother trying to process packages 201 through 957.

efg

Earl F. Glynn
Scientific Programmer
Bioinformatics
Stowers Institute for Medical Research



More information about the R-help mailing list