0

I'm using helpExtract function from SOfun package (written by @Ananda Mahto). The package SOfun can be installed from github using the following command:

devtools::install_github("mrdwab/SOfun")

library(SOfun)

The following command gives in the package document works fine.

textConnection(
  helpExtract(Function = cor, section = "Examples", type = "s_text")
  )

However the same command when using the argument package= fails.

textConnection(
  helpExtract(Function = cor, section = "Examples", type = "s_text", package = "stats")
)

And throws the follow error message:

Error in textConnection(helpExtract(Function = cor, section = "Examples",  : 
  argument 'object' must deparse to a single character string
halfer
  • 19,824
  • 17
  • 99
  • 186
MYaseen208
  • 22,666
  • 37
  • 165
  • 309

1 Answers1

3

As mentioned, this is a problem that stems from deparse. I don't have time to dig further to explain the error, but the following works for me:

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

That is, store the output of helpExtract as a variable in a hidden chunk, and use textConnection on that variable.

A5C1D2H2I1M1N2O1R2T1
  • 190,393
  • 28
  • 405
  • 485