"Earl F. Glynn" <[EMAIL PROTECTED]> writes: > "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.
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? How about this: safeRequire <- function(x) { tryCatch(require(x, character.only=TRUE), error=function(e) FALSE) } And then replace the call to require in findfuns(). + seth ______________________________________________ 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.