我可以使用R或help()获得有关html格式的任何?函数的帮助。我想知道是否可以在R文档中使用.tex或.Rnw格式的.Rnw函数的帮助。提前谢谢你的帮助。
?lm发布于 2014-01-07 13:07:13
我发现诺姆·罗斯的一篇博文提到了这个问题:http://www.r-bloggers.com/printing-r-help-files-in-the-console-or-in-knitr-documents/
该功能可通过github在Noam的包noamtools中获得
library(devtools)
install_github("noamtools", "noamross")
library(noamtools)
help_console(lm, format = "latex")为了子孙后代,他们创造的功能是
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)
}像这样使用它来获得乳胶输出
help_console(lm, format = "latex")发布于 2014-01-07 12:35:25
来自?help,
可提供下列类型的帮助: 纯文本帮助 具有指向其他主题的超链接的help,由browseURL在浏览器中显示。如果由于某种原因help不可用(请参阅startDynamicHelp),则将使用纯文本帮助。 有关帮助,排版为PDF -请参阅“脱机帮助”一节。
所以你必须从这些格式中的一种工作。
https://stackoverflow.com/questions/20969313
复制相似问题