gpt4 book ai didi

`.tex` 或 `.Rnw` 格式的 R 函数帮助

转载 作者:行者123 更新时间:2023-12-04 21:53:32 24 4
gpt4 key购买 nike

我可以在任何 R 上获得帮助函数在 html格式使用 ?help() .我想知道我是否可以在 R 上获得帮助.tex 中的函数或 .Rnw.tex 中使用的格式文件。在此先感谢您的帮助。

?lm

最佳答案

我在此处找到了 Noam Ross 的一篇博客文章,其中提到了这个问题:http://www.r-bloggers.com/printing-r-help-files-in-the-console-or-in-knitr-documents/

该功能在 Noam 的软件包 noamtools 中可用,可通过 github 获得

 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)
}

像这样使用它来获得 latex 输出
help_console(lm, format = "latex")

关于 `.tex` 或 `.Rnw` 格式的 R 函数帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20969313/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com