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:

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:

 

console full of code

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:

 

empty r console

Figure 2: Empty RStudio Console.

 

Completely empty!

 

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:

cat("\014")

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:

 

 

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 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!

 



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.

Menu
Top