I can get help on any R
function in html
format using ?
or help()
. I wonder if I can get help on R
functions in .tex
or .Rnw
format to use in .tex
dociument. Thanks in advance for your help.
?lm
I can get help on any R
function in html
format using ?
or help()
. I wonder if I can get help on R
functions in .tex
or .Rnw
format to use in .tex
dociument. Thanks in advance for your help.
?lm
I found a blog post by Noam Ross that references this problem here: http://www.r-bloggers.com/printing-r-help-files-in-the-console-or-in-knitr-documents/
The function is available in Noam's package noamtools available via github
library(devtools)
install_github("noamtools", "noamross")
library(noamtools)
help_console(lm, format = "latex")
For sake of posterity the function they create is
help_console <- function(topic, format=c("text", "html", "latex", "Rd"),
lines=NULL, before=NULL, after=NULL) {
format=match.arg(format)
if (!is.character(topic)) topic <- deparse(substitute(topic))
helpfile = utils:::.getHelpFile(help(topic))
hs <- capture.output(switch(format,
text=tools:::Rd2txt(helpfile),
html=tools:::Rd2HTML(helpfile),
latex=tools:::Rd2latex(helpfile),
Rd=tools:::prepare_Rd(helpfile)
)
)
if(!is.null(lines)) hs <- hs[lines]
hs <- c(before, hs, after)
cat(hs, sep="\n")
invisible(hs)
}
Use it like this to get latex output
help_console(lm, format = "latex")
From ?help
,
The following types of help are available:
Plain text help
HTML help pages with hyperlinks to other topics, shown in a browser by browseURL. If for some reason HTML help is unavailable (see startDynamicHelp), plain text help will be used instead.
For help only, typeset as PDF – see the section on ‘Offline help’.
So you'd have to work from one of those formats.