Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RMarkdown code evaluation until command

I'm using RMarkdown where I'm building my analysis. The final output will be an html document. Actually I've got a core code which will be the final document and, after the end, I've got many lines of code with chunks and sentences that at the moment are not useful, but could be included in the final document.

    Does a command exist to say to RMarkdown to evaluate the code until that point?

Not just like eval=FALSE for chunks (I've got also plain text), but something like \end{document} in TeX. I don't want just to comment plain text and put eval=FALSE as chunks options.

I tried to google and read in the RMarkdown documentation, but I found nothing.

Thanks everybody! And forgive me for my poor English...

like image 303
Simone Marini Avatar asked Feb 20 '26 13:02

Simone Marini


1 Answers

From the documentation of knit_exit():

Sometimes we may want to exit the knitting process early, and completely ignore the rest of the document. This function provides a mechanism to terminate knit().

Example:

Text.

```{r}
print(1)
```

More text.

```{r}
knitr::knit_exit()
```

Ignored.

```{r}
print("Ignored.")
```

Everything after knit_exit() will be ignored. This works for all output formats.

The code above produces:

enter image description here

like image 170
CL. Avatar answered Feb 23 '26 01:02

CL.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!