我从@AnandaMahto编写的这里中获取了以下代码。此函数以前运行良好,但停止使用R 3.1.1和knitr 1.6.10。
\documentclass{article}
\begin{document}
<<echo=FALSE>>=
library(devtools)
source_gist("https://gist.github.com/mrdwab/7586769")
@
\Sexpr{knit_child(textConnection(helpExtract(cor, section="Arg", type = "s_text")),
options = list(tidy = FALSE, eval = FALSE))}
\Sexpr{knit_child(textConnection(helpExtract(cor, type = "s_code")),
options = list(tidy = FALSE, eval = FALSE))}
<<tidy=TRUE>>=
## normal R code
args(lm)
@
\end{document}发布于 2014-07-26 06:13:40
作为一种即席解决方案,您可以避免使用library(devtools)。
<<echo=FALSE>>=
devtools::source_gist("https://gist.github.com/mrdwab/7586769")
@但基本的解决方案是修改helpExtract函数。在第3行,utils:::.getHelpFile(help(A))应该是utils:::.getHelpFile(utils::help(A))
这是由一些deparse和substitute链引起的。我不确定这是否是devtools的一个bug,但至少我认为这是devtools包的一个坏行为,所以我会让@hadley知道这个行为。
https://stackoverflow.com/questions/24914419
复制相似问题