In R Markdown in Rstudio, How to Prevent the Source Code from Running Off a PDF Page

prevent r-markdown from unfolding code/function

did you try this answer ?
I tried to reproduce your problem in my RStudio v1.2.5033 and it worked for me.



Tools > Global Options > R Markdown > Uncheck: Show output inline for all R Markdown Documents.

That should disable inline code chunk output when you're editing R Markdown documents.

Does that get you what you're asking?



How to show code but hide output in RMarkdown?

As @ J_F answered in the comments, using {r echo = T, results = 'hide'}.

I wanted to expand on their answer - there are great resources you can access to determine all possible options for your chunk and output display - I keep a printed copy at my desk!

You can find them either on the RStudio Website under Cheatsheets (look for the R Markdown cheatsheet and R Markdown Reference Guide) or, in RStudio, navigate to the "Help" tab, choose "Cheatsheets", and look for the same documents there.

Finally to set default chunk options, you can run (in your first chunk) something like the following code if you want most chunks to have the same behavior:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = T,
results = "hide")
```

Later, you can modify the behavior of individual chunks like this, which will replace the default value for just the results option.

```{r analysis, results="markup"}
# code here
```


Related Topics



Leave a reply



Submit