helpExtract功能在R 3.1.1和knitr 1.6.10中不起作用

helpExtract功能在R 3.1.1和knitr 1.6.10中不起作用,r,latex,knitr,sweave,R,Latex,Knitr,Sweave,我从@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(helpExt

我从@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}
\documentclass{article}
\开始{document}
=
图书馆(devtools)
资料来源https://gist.github.com/mrdwab/7586769")
@
\Sexpr{knit_child(textConnection(helpExtract(cor,section=“Arg”,type=“s_text”)),
选项=列表(tidy=FALSE,eval=FALSE))}
\Sexpr{knit_child(textConnection(helpExtract(cor,type=“s_code”)),
选项=列表(tidy=FALSE,eval=FALSE))}
=
##正规R码
args(lm)
@
\结束{document}

作为一种特殊的解决方案,您可以通过避免使用
库(devtools)

=
开发工具::源代码https://gist.github.com/mrdwab/7586769")
@
但基本的解决方案是修改
helpExtract
函数。 在第3行,
utils::.getHelpFile(help(A))
应该是
utils::.getHelpFile(utils::help(A))

这是由一些
deparse
substitute
链引起的。
我不确定这是否是
devtools
的一个bug,但至少我认为这是
devtools
包的一个坏行为,所以我会让@hadley知道这个行为。

让我们看看@AnandaMahto是否有任何解决方案。奇怪。如果函数的内容是逐行运行的,它们似乎输出了预期的结果……@AnandaMahto:它对您有效吗?我认为
source\u-gist
会产生问题。如果我在.Rnw中定义函数,这是可行的。@kohske,为什么会是这种情况?+1用于侦查。正如我在评论中提到的,似乎从包中加载函数也可以。是的,这是因为包中的搜索路径不同,因此即使用户调用
library(devtools)
在包中调用
help
也会引用
utils::help
。酷。然后,我将修改函数以显式引用
utils::help
<<echo=FALSE>>=
devtools::source_gist("https://gist.github.com/mrdwab/7586769")
@