How do you clear the R console in OS X (or Ubuntu)
27,142
Solution 1
Command+Option+L in R for Mac OS X
Ctrl+L in RStudio for Mac OS X
Solution 2
Since you ask for Ubuntu as well, it's simply Ctrl-L from a standard gnome-terminal.
Solution 3
I discovered that you call also type unix commands with the system()
function.
system('clear')
Solution 4
For what it's worth, my console to R is provided by ESS on whichever platform I use -- and as that is within Emacs, it is always Ctrl-l (or C-l in the common shorthand for Emacs).
Solution 5
Create this function:
cls <- function() cat(rep("\n",100))
Then call it:
cls()
Compatible with Windows, Linux and Mac.
Author by
Milktrader
Updated on March 17, 2020Comments
-
Milktrader over 4 years
Possible Duplicate:
Function to Clear the Console in RIn bash, its like this:
$ clear
And I believe it's CTL-L in the Windows version of R. But how do you clear the R console in Unix-type R Consoles? Do you need to write a special function and what would that look like?
-
Daniel Dickison over 13 yearsHere's a handy tip for finding any menu command in OS X: cmd-shift-/ to bring up the Help menu, type "clear", see where the relevant menu items are.
-
vol7ron almost 11 yearsinsert 100 newlines == clear? false
-
Justace Clutter over 8 yearsThere is a much better way to do this. Rather than put 100 new lines, which is not really a clear, you can also print out the code for cntl-L.
-
Sam over 7 yearsif you wanna get fancy:
clear <- function() { cat(rep("\n", Sys.getenv("LINES"))); }
. But, yeah, while not a true "clear-screen," it does clear the screen and add a useful bit of space between code segments.