[R] how to clear screen in R-console?

Paul Roebuck roebuck at mdanderson.org
Fri Feb 17 19:14:57 CET 2006


On Thu, 16 Feb 2006, Henrik Bengtsson wrote:

> On 2/16/06, Michael <comtech.usa at gmail.com> wrote:
>
> > On 2/16/06, Christian Schulz <ozric at web.de> wrote:
> > >
> > > >How to clear the screen in R-console?
> > >
> > > ctrl - e & l
> >
> > Any funcation that is callable from my program, instead of
> > pressing keys?
>
> depends on what type of terminal you are running.  For example, if you
> run R in a VT100 terminal, you can try
>
> cat("The following VT100 escape sequence will clear the screen on a
> VT100 terminal\n")
> cat("\033[2J")  # <ESC>[2J  == Clear Screen
> cat("If the screen was cleared you should only see this sentence.\n")
>
> i.e.
>
> vt100ClearScreen <- function(...) cat("\033[2J")
>

On my terminal, this required the addition of cursor homing
to replicate the effects of using the OS to clear the screen.

system_cls <- function() system("clear")
vt100_cls  <- function() cat("\033[2J\033[H")

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)




More information about the R-help mailing list