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

Duncan Murdoch murdoch at stats.uwo.ca
Fri Feb 17 15:05:38 CET 2006


On 2/16/2006 3:22 PM, Michael wrote:
> I am actually using Rgui on Windows...
> 
> What can I do?
> 
> There is no way to programmatically clear screen?

Of course there's a way, or Rgui couldn't do it.  The menu item calls 
the function "menuclear", which is exported from R.dll, currently with 
definition

void menuclear(control m)
{
     consoleclear(RConsole);
}

You don't have access to a valid value for m, but since it's not used, 
that shouldn't matter.  Write a C function to import this function from 
R.dll and call it.

You shouldn't count on your function working in any newer release; 
menuclear is not part of the published API.  And you shouldn't expect 
your code to work if you're running in Rterm or on any platform other 
than Windows.  But if you're desperate to call it, you can.

Brian Ripley has made many of the menu operations in Rgui available 
through R functions.  Perhaps they all should be; would you like to 
write the code to do it?  If so, please write up the R interface before 
you go ahead and do all the work.  I expect there will be some 
disagreement there, and it might affect the implementation.

Duncan Murdoch
> 
> On 2/16/06, Henrik Bengtsson <hb at maths.lth.se> wrote:
>>
>> Hi,
>>
>> 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")
>>
>> Some links:
>> http://www.fh-jena.de/~gmueller/Kurs_halle/esc_vt100.html
>> http://en.wikipedia.org/wiki/VT100
>>
>> Note, this is not guaranteed to work everywhere.  To the best of my
>> knowledge, you will not be able to do anything like this in Rgui on
>> Windows.
>>
>> Cheers
>>
>> Henrik
>>
>>
>> On 2/16/06, Michael <comtech.usa at gmail.com> wrote:
>> > Any funcation that is callable from my program, instead of pressing
>> keys?
>> >
>> > Thanks a lot!
>> >
>> >
>> > On 2/16/06, Christian Schulz <ozric at web.de> wrote:
>> > >
>> > > ctrl - e & l
>> > >
>> > > >HI all,
>> > > >
>> > > >How to clear the screen in R-console?
>> > > >
>> > > >Thanks a lot@!
>> > > >
>> > > >       [[alternative HTML version deleted]]
>> > > >
>> > > >______________________________________________
>> > > >R-help at stat.math.ethz.ch mailing list
>> > > >https://stat.ethz.ch/mailman/listinfo/r-help
>> > > >PLEASE do read the posting guide!
>> > > http://www.R-project.org/posting-guide.html
>> > > >
>> > > >
>> > > >
>> > >
>> > >
>> > >
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at stat.math.ethz.ch mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>> >
>> >
>>
>>
>> --
>> Henrik Bengtsson
>> Mobile: +46 708 909208 (+1h UTC)
>>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list