I would like to include function documentation from the help file in a sweave document. I tried the following sweave block
<<>>=
?lm
@
but I get error messages when calling Sweave
on the Rnw file. How can I include the entire help message in the document?
The key to this is really figuring out how to get the information you desire as a character string.
help("lm")
opens up the help file for the relevant function, but not in the console. utils:::.getHelpFile
gives you the Rd version of that file. tools:::Rd2txt
to convert it to text...capture.output
.Those are essentially the steps contained in the first few lines of helpExtract
from my "SOfun" package. That function, however, captures just the requested section.
Instead, if you can settle for just the text, you can do something along the lines of:
gsub("_\b", "",
capture.output(tools:::Rd2txt(
utils:::.getHelpFile(utils::help("lm")))))