R函数以`.tex`或`.Rnw`格式提供帮助

时间:2014-01-07 10:31:34

标签: r latex noamtools

我可以使用Rhtml?格式获取有关help()个功能的帮助。我想知道我是否可以R.tex格式获取.Rnw个函数的帮助,以便在.tex dociument中使用。在此先感谢您的帮助。

?lm

2 个答案:

答案 0 :(得分:6)

我发现Noam Ross的博客文章在此引用了这个问题: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")

答案 1 :(得分:0)

来自?help

  

提供以下类型的帮助:

     

纯文字帮助

     

带有指向其他主题的超链接的HTML帮助页面,由browseURL在浏览器中显示。如果由于某种原因HTML帮助不可用(请参阅startDynamicHelp),则将使用纯文本帮助。

     

仅限帮助,排版为PDF - 请参阅“离线帮助”部分。

所以你必须使用其中一种格式。

相关问题