Working with bookdown, and I was hoping to put code chunks and their output in the same code block upon compiling, so I set the code chunk option collapse = TRUE globally. However, this added a line at the beginning of the compiled code chunk.
For example, this code chunk:
```{r, collapse = TRUE}
# unwanted line above this comment
```
produces this code block:
# unwanted line above this comment
Desired result is
# unwanted line above this comment
I tried strip.white = TRUE, but that didn't work. I'm aware that I can remove the spacing from the r code chunk like so
```{r, collapse = TRUE}
# unwanted line above this comment
```
but, I find the code chunk with extra spacing easier to read, especially when working on long, complicated documents. So, if there's a solution that doesn't involved compact r code chunks, I'd be grateful to know what it is.