Clear All Plots in RStudio Using R Code (Example)

 

This article shows how to remove all plots that are shown in RStudio in the R programming language.

Table of contents:

Let’s get started…

 

Creation of Example Plots

As a first step, we can create some plots in RStudio:

plot(1:10)                     # Plot No. 1
plot(10:1)                     # Plot No. 2
plot(1)                        # Plot No. 3

Have a look at your RStudio plots window.

It should show the last graphic that we have created above (i.e. plot(1)) and you should be able to switch back to the other two graphs in the plots window.

 

Example: Remove All Plots from RStudio Using dev.off() & dev.list() Functions

This example explains how to clear all plots from the RStudio plots window using R programming code.

Have a look at the following R syntax:

dev.off(dev.list()["RStudioGD"]) # Apply dev.off() & dev.list()

After executing this R code, all plots should be removed from RStudio.

 

Video & Further Resources

I have recently published a video instruction on my YouTube channel, which shows the R code of this article. You can find the video below.

 

 

Furthermore, you may have a look at the related tutorials on my website. I have published several tutorials already:

 

To summarize: In this R tutorial you have learned how to remove all graphs that are shown in RStudio. Let me know in the comments section below, in case you have any additional questions.

 

Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Top