Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make R Studio plots only show up in new window

Tags:

r

rstudio

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 plot a graph, the other panes automatically pop out of the side bar to show me the Plot pane. Because I work on a laptop, this makes everything too small to see. By clicking the Zoom button on the Plots pane, I can get the plot also show up in a new window, but does not prevent the Plots pane from showing up.

Is there a way to "disable" the Plots pane in R Studio, and force plots show up in a new window?

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils    
[5] datasets  methods   base     

other attached packages:
[1] ggplot2_2.2.1     jsonlite_1.4     
[3] data.table_1.10.4

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.2-6
 [3] scales_0.4.1     lazyeval_0.2.0  
 [5] plyr_1.8.4       tools_3.2.3     
 [7] gtable_0.1.2     tibble_1.3.0    
 [9] curl_2.5         Rcpp_0.12.10    
[11] grid_3.2.3       munsell_0.4.2   
> 
like image 395
sam Avatar asked Oct 02 '17 22:10

sam


Video Answer


2 Answers

The dev.new() function will open a new plot window, which then becomes the target for all plots.

If you wish to open another window you can run the command a second time to open a second window.

dev.off() will shut down the window (in the order they were opened by default).

You can see how to control multiple graphics devices in the documentation here.

like image 168
JegarP Avatar answered Sep 29 '22 02:09

JegarP


Commenting the following lines in C:\Program Files\RStudio\R\Tools.R seems to work (it may be necessary to edit the file as administrator):

# set our graphics device as the default and cause it to be created/set
.rs.addFunction( "initGraphicsDevice", function()
{
   # options(device="RStudioGD")
   # grDevices::deviceIsInteractive("RStudioGD")
  grDevices::deviceIsInteractive()
})
like image 43
Rubén Fernández-Casal Avatar answered Sep 29 '22 02:09

Rubén Fernández-Casal