In R markdown in RStudio, how can I prevent the source code from running off a pdf page?

后端 未结 1 937
无人共我
无人共我 2020-11-29 01:46

I currently have some code that looks like so:

```{r, tidy=TRUE}
plot(DT$age, DT$height, xlab = \"Age of participant in Trials\", ylab = \"Height of particip         


        
相关标签:
1条回答
  • 2020-11-29 02:19

    Use the width.cutoff argument inside tidy.opts knitr options to specify the output width :

    ```{r, tidy=TRUE, tidy.opts=list(width.cutoff=60)}
    plot(DT$age, DT$height, xlab = "Age of participant in Trials", ylab = "Height of participant in trials")
    ```
    

    You can define this option globally for your whole file with a chunk like this :

    ```{r}
    library(knitr)
    opts_chunk$set(tidy.opts=list(width.cutoff=60),tidy=TRUE)
    ```
    

    The tidy.opts options are passed to the formatR package which does the tidying (if I understand correctly). In-depth informations about formatR can be found here :

    http://yihui.name/formatR/

    0 讨论(0)
提交回复
热议问题