The short answer is you cannot. Inline R code is always evaluated.
When it is not evaluated, I doubt if your output still makes sense,
e.g. "The value of x is `r x`." becomes "The value of x is ." That
sounds odd to me.

If you want to disable the evaluate of inline code anyway, you may use
a custom function to do it. e.g.

cond_eval = function(x) {
  if (isTRUE(knitr::opts_chunk$get('eval'))) x
}

Then `r cond_eval(x)` instead of `r x`.

Regards,
Yihui
--
Yihui Xie <xieyi...@gmail.com>
Web: http://yihui.name


On Tue, Nov 10, 2015 at 4:40 AM, Witold E Wolski <wewol...@gmail.com> wrote:
> I do have an Rmd where I would like to conditionally evaluate the second part.
>
> So far I am working with :
>
> ```{r}
> if(length(specLibrary@ionlibrary) ==0){
>   library(knitr)
>   opts_chunk$set(eval=FALSE, message=FALSE, echo=FALSE)
> }
> ```
>
> Which disables the evaluation of subsequent chunks.
>
> However my RMD file contains also these kind of snippets : `r `
>
> How do I disable them?
>
> regards
>
>
>
> --
> Witold Eryk Wolski

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to