'prevent r-markdown from unfolding code/function
Here is my r-markdown code:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
test_funciton <- function(){<->}
3+5
```
observe that test_function is folded. Now when I execute 3+5 line I end up with with the following view:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
test_funciton <- function(){
print('test')
}
3+5
```
test_function is now unfolded. I wonder if I can prevent this unfolding behavior?
Solution 1:[1]
In case you are still having this issue, maybe changing where the '}' is located at the bottom of your unfolded function may help. Instead of:
f <- function(a){ k <- sqrt(a) return(k) }
Try: f <- function(a){ k <- sqrt(a) return(k) }
It worked for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
