Make R Studio plots only show up in new window

前端 未结 5 486
鱼传尺愫
鱼传尺愫 2021-02-08 19:26

When using R Studio, I usually just work with an .R file stacked on top of the Console. I keep the other panes (Environment, History, Files, etc) hidden.

But whenever I

5条回答
  •  伪装坚强ぢ
    2021-02-08 20:01

    You can force RStudio to show plots in the Source window if you use R Markdown. In a Rmd file, plots are shown together with code; it's called an R Markdown notebook. You can set the size of the plots too, in what is called an R code chunk:

    ```{r fig.height = 2, fig.width = 3}
    plot(mpg ~ wt, mtcars)
    ```
    

    When you run the chunk, the plot is shown below it.

    If you want to set the plot size for the whole notebook, set the package option using opts_knit and opts_chunk, for example:

    ```{r setup} 
    library(knitr) 
    opts_knit$set(global.par = TRUE) 
    opts_chunk$set(fig.width = 4.5, fig.height = 3.5)
    ```
    

    For more information, see here and here.

提交回复
热议问题