[R] Knitr: setting echo = FALSE globally [RESOLVED]
Rich Shepard
rshepard at appl-ecosys.com
Tue Jul 21 17:30:09 CEST 2015
On Mon, 20 Jul 2015, John Kane wrote:
> I have no idea wha that chunk is not working but I think you can get the
> same result using the old method Stick the following in an ERT box:
>
> <<set-ops, echo = FALSE>>=
> opts_chunk$set(echo = FALSE)
> @
John,
My original response was too large (3 attached PDF files) and was held for
moderator approval which is no longer needed.
I found the magic solution; looks awkward, but it works.
Near the top of the document (well before any R code) I insert a knitr
chunk containing the directive, opts_chunk$set(echo=FALSE). This is
immediately followed by an ERT box as above. The double whammy prevents R
code from echoing ... except for the contents of the leading chunk itself.
Adding the option, echo=FALSE, to that leading chunk prevents it from
displaying.
Note that both the chunk with opts_chunk$set() and the ERT is required to
prevent R code from displaying. No chunk but ERT box does not stop the
echoing.
Thanks for the pointer,
Rich
More information about the R-help
mailing list