Clear R and RStudio Console (2 Examples)
This article explains how to clear the console in R and RStudio.
I will show you two alternatives for clearing the console. More precisely, this article contains the following contents:
- Clear R and RStudio Console with Shortcut
- Clear R and RStudio Console with Code
- Video & Further Resources
You’re here for the answer, so let’s get straight to it.
Clear R and RStudio Console with Shortcut
Let’s assume your R or RStudio console (i.e. the panel that is typically located at the bottom left of RStudio) looks similar to this:
Figure 1: RStudio Console is Full with Code.
You can clear this code in the console with the following shortcut on your keyboard:
CTRL + L
If you press these click these keys together, your RStudio console will look as follows:
Figure 2: Empty RStudio Console.
Clear R and RStudio Console with Code
In some cases, it might be advantageous to clear the console with some R code (e.g. when you want to automatize some processes within a function). If you want to remove everything from the console with an R code, you can use the cat function:
Fill up your console window again and then run the code above. Everything in your console will be removed.
Video & Further Resources
It’s a bit difficult to explain shortcuts etc. in a written tutorial. For that reason, I have created a video on my YouTube channel which is showing the previous exampled live. You can find the video below:
Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.
If you accept this notice, your choice will be saved and the page will refresh.
If you want to learn more about R in general, you could also have a look at the other R tutorials of my homepage. You can find a list of interesting tutorials below:
I hope you learned in this tutorial how to delete and clean everything in the console of R or RStudio. However, if you have any further questions please let me know in the comments below. Furthermore, don’t forget to subscribe to my email newsletter for regular updates on new R tutorials. It’s free!