I am wondering if there is a function to clear the console in R and, in particular, RStudio I am looking for a function that I can type into the console, and not a keyboard shortcut.
Someone has already provided such a function in this StackExchange post from 2010. Unfortunately, this depends on the RCom package and will not run on Mac OS X.
clcwith this script clc.R that I development. How does it work?clc<-0;class(clc) <- 'cleanup';print.cleanup <- function(cleanupObject) cat("\f"). The last line corresponds to RStudio but in terminal change it byprint.cleanup <- function(cleanupObject) cat(c("\033[2J","\033[H")). The clc.R contains more details.