help
itself doesn't return anything useful. To get the help text, you can read the contents of the help database for a package, and parse that.
extract_help <- function(pkg, fn = NULL, to = c("txt", "html", "latex", "ex"))
{
to <- match.arg(to)
rdbfile <- file.path(find.package(pkg), "help", pkg)
rdb <- tools:::fetchRdDB(rdbfile, key = fn)
convertor <- switch(to,
txt = tools::Rd2txt,
html = tools::Rd2HTML,
latex = tools::Rd2latex,
ex = tools::Rd2ex
)
f <- function(x) capture.output(convertor(x))
if(is.null(fn)) lapply(rdb, f) else f(rdb)
}
pkg
is a character string giving the name of a package
fn
is a character string giving the name of a function within that package. If it is left as NULL
, then the help for all the functions in that package gets returned.
to
converts the help file to txt, tml or whatever.
Example usage:
#Everything in utils
extract_help("utils")
#just one function
extract_help("utils", "browseURL")
#convert to html instead
extract_help("utils", "browseURL", "html")
#a non-base package
extract_help("plyr")