You can use the chunk option tidy=TRUE
to automatically insert line breaks in the code.
---
output: pdf_document
---
```{r, tidy = TRUE}
c(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
```
The linebreaks are inserted by formatR::tidy_source()
. See https://yihui.org/knitr/options/#code-decoration for more details.
chunk_content <- "c(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)"
formatR::tidy_source(text = chunk_content, width.cutoff = 30)
#> c(1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
#> 1, 2, 3, 4, 5, 6, 7, 8, 9,
#> 0, 1, 2, 3, 4, 5, 6, 7, 8,
#> 9, 0, 1, 2, 3, 4, 5, 6, 7,
#> 8, 9, 0)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.