Function to clear the console in R and RStudio Function to clear the console in R and RStudio r r

Function to clear the console in R and RStudio


cat("\014")  

is the code to send CTRL+L to the console, and therefore will clear the screen.

Far better than just sending a whole lot of returns.


If you are using the default R console, the key combination Option + Command + L will clear the console.


You may define the following function

clc <- function() cat(rep("\n", 50))

which you can then call as clc().