knitr: How to prevent text wrapping in output?

后端 未结 1 1697
太阳男子
太阳男子 2020-11-30 05:13

I am having a problem with text wrapping in code output chunks in knitr when knitting to HTML.

For example, if I run the following:

matrix(rnorm(60,          


        
相关标签:
1条回答
  • 2020-11-30 05:54

    Adding something like options(width=120) to your document would allow you to override the default wrapping width.

    Be careful about going too wide though; when converting to PDF or other formats, the default is pretty much just right!

    As an example, I use Knitr from RStudio, and type my document as a R markdown document. My document "options" at the start might be something like this:

    ```{r set-options, echo=FALSE, cache=FALSE}
    options(width=80)
    opts_chunk$set(comment = "", warning = FALSE, message = FALSE, echo = TRUE, tidy = TRUE, size="small")
    read_chunk("some/script/I/want/to/load.R")
    ```
    
    0 讨论(0)
提交回复
热议问题