我正在使用来自helpExtract包的SOfun函数(由@Ananda编写)。可以使用以下命令从SOfun中安装包github:
devtools::install_github("mrdwab/SOfun")
library(SOfun)下面的命令在包文档中运行良好。
textConnection(
helpExtract(Function = cor, section = "Examples", type = "s_text")
)但是,在使用参数package=时,相同的命令会失败。
textConnection(
helpExtract(Function = cor, section = "Examples", type = "s_text", package = "stats")
)并抛出以下错误消息:
Error in textConnection(helpExtract(Function = cor, section = "Examples", :
argument 'object' must deparse to a single character string发布于 2015-01-09 08:53:32
如前所述,这是一个源自deparse的问题。我没有时间进一步研究来解释错误,但以下几点对我来说是有效的:
\documentclass{article}
\begin{document}
<<echo=FALSE>>=
library(SOfun)
x <- helpExtract(Function = cor, section = "Examples",
type = "s_text", package = "stats")
@
\Sexpr{knit_child(textConnection(x),
options = list(tidy = FALSE, eval = FALSE))}
\end{document}也就是说,将helpExtract的输出存储为隐藏块中的变量,并对该变量使用textConnection。
https://stackoverflow.com/questions/27856126
复制相似问题