Re: [R] listing all functions in R

From: Earl F. Glynn <efg_at_stowers-institute.org>
Date: Tue 09 Jan 2007 - 22:51:05 GMT

"Seth Falcon" <sfalcon@fhcrc.org> wrote in message news:m23b6k5idc.fsf@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



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 Wed Jan 10 10:31:16 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 Wed 10 Jan 2007 - 00:30:25 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.