Search code examples
rlatexknitrsweaveformatr

knitr chunk option code to input code into a chunk does not work in R 3.1.1 with knitr 1.6.10


I'm using knitr 1.6.10 in R 3.1.1. The chunk option code seems like does not work. My MWE in .Rnw format is below:

\documentclass{article} 

\begin{document}
<< packages, include=FALSE, cache=FALSE>>=
library(knitr)
library(formatR)
@

<<test, code=formatR::usage(lm), eval=FALSE>>=
@

\end{document}

Previously this function was working (See here) but it is not working even-though formatR::usage(lm) working outside chunk code.


Solution

  • The answer you mentioned has stated that the formatR version must be >= 0.10.3, which is a development version.

    devtools::install_github('yihui/formatR')