Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code to clear all plots in RStudio

Tags:

plot

r

rstudio

I have code to clear the workspace: rm(list=ls()) and code to clear the console: cat("\014")

Is there code to clear all plots from Rstudio?

like image 824
dpel Avatar asked Mar 25 '14 16:03

dpel


1 Answers

dev.off() closes the current graphical device. This clears all of the plots for me in RStudio as long as I don't have a different graphical device open at the moment. If you do have other graphical devices open then you can use dev.list() to figure out which graphical device is RStudio's. The following should do that but I haven't tested it thoroughly.

dev.off(dev.list()["RStudioGD"]) 

But if you aren't doing anything else then just using dev.off() should take care of it.

like image 172
Dason Avatar answered Sep 20 '22 16:09

Dason