Possible Duplicate:
R help page as object
I can do
temp <- help('ls')
But I can't get a handle on this object. I don't think there's much meat in it except a call is there? unclass, str, attributes don't seem to lead anywhere.
I would like to, for example,
(1) Extract the text of the Details section of the help for ls; and
(2) Extract all the text into one big string.
Any ideas? Thanks
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 packagefn 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")
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With