Quantcast

how to clear screen in R-console?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to clear screen in R-console?

LosemindL
HI all,

How to clear the screen in R-console?

Thanks a lot@!

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Malcolm Campbell

Ctrl+L should work

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Michael
Sent: 16 February 2006 10:33
To: [hidden email]
Subject: [R] how to clear screen in R-console?

HI all,

How to clear the screen in R-console?

Thanks a lot@!

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

christian schulz
In reply to this post by LosemindL
ctrl - e & l

>HI all,
>
>How to clear the screen in R-console?
>
>Thanks a lot@!
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>  
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

LosemindL
Any funcation that is callable from my program, instead of pressing keys?

Thanks a lot!


On 2/16/06, Christian Schulz <[hidden email]> wrote:

>
> ctrl - e & l
>
> >HI all,
> >
> >How to clear the screen in R-console?
> >
> >Thanks a lot@!
> >
> >       [[alternative HTML version deleted]]
> >
> >______________________________________________
> >[hidden email] 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]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Henrik Bengtsson-2
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 <[hidden email]> wrote:

> Any funcation that is callable from my program, instead of pressing keys?
>
> Thanks a lot!
>
>
> On 2/16/06, Christian Schulz <[hidden email]> wrote:
> >
> > ctrl - e & l
> >
> > >HI all,
> > >
> > >How to clear the screen in R-console?
> > >
> > >Thanks a lot@!
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > >______________________________________________
> > >[hidden email] 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]]
>
> ______________________________________________
> [hidden email] 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)

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

LosemindL
I am actually using Rgui on Windows...

What can I do?

There is no way to programmatically clear screen?

On 2/16/06, Henrik Bengtsson <[hidden email]> 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 <[hidden email]> wrote:
> > Any funcation that is callable from my program, instead of pressing
> keys?
> >
> > Thanks a lot!
> >
> >
> > On 2/16/06, Christian Schulz <[hidden email]> wrote:
> > >
> > > ctrl - e & l
> > >
> > > >HI all,
> > > >
> > > >How to clear the screen in R-console?
> > > >
> > > >Thanks a lot@!
> > > >
> > > >       [[alternative HTML version deleted]]
> > > >
> > > >______________________________________________
> > > >[hidden email] 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]]
> >
> > ______________________________________________
> > [hidden email] 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]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Henrik Bengtsson-2
On 2/16/06, Michael <[hidden email]> wrote:
> I am actually using Rgui on Windows...
>
> What can I do?

The only way I can think of is to do write a lot of empty lines, e.g.

cat(rep("\n",64))

You will not get the prompt at the upper-left corner.   Better than nothing.

/Henrik

> There is no way to programmatically clear screen?
>
> On 2/16/06, Henrik Bengtsson <[hidden email]> 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 <[hidden email]> wrote:
> > > Any funcation that is callable from my program, instead of pressing
> > keys?
> > >
> > > Thanks a lot!
> > >
> > >
> > > On 2/16/06, Christian Schulz <[hidden email]> wrote:
> > > >
> > > > ctrl - e & l
> > > >
> > > > >HI all,
> > > > >
> > > > >How to clear the screen in R-console?
> > > > >
> > > > >Thanks a lot@!
> > > > >
> > > > >       [[alternative HTML version deleted]]
> > > > >
> > > > >______________________________________________
> > > > >[hidden email] 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]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Duncan Murdoch
In reply to this post by LosemindL
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 <[hidden email]> 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 <[hidden email]> wrote:
>> > Any funcation that is callable from my program, instead of pressing
>> keys?
>> >
>> > Thanks a lot!
>> >
>> >
>> > On 2/16/06, Christian Schulz <[hidden email]> wrote:
>> > >
>> > > ctrl - e & l
>> > >
>> > > >HI all,
>> > > >
>> > > >How to clear the screen in R-console?
>> > > >
>> > > >Thanks a lot@!
>> > > >
>> > > >       [[alternative HTML version deleted]]
>> > > >
>> > > >______________________________________________
>> > > >[hidden email] 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]]
>> >
>> > ______________________________________________
>> > [hidden email] 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]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Marcus Leinweber
In reply to this post by LosemindL
have already tried this?

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/55752.html

m.


> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Michael
> Sent: Thursday, February 16, 2006 9:23 PM
> To: Henrik Bengtsson
> Cc: [hidden email]
> Subject: Re: [R] how to clear screen in R-console?
>
> I am actually using Rgui on Windows...
>
> What can I do?
>
> There is no way to programmatically clear screen?
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Gabor Grothendieck
Here is a translation of Norm Olsen's vbscript code into pure R.
This is intended for use with the Windows Rgui interface.

cls <- function() {
        require(RDCOMClient)
        wsh <- COMCreate("Wscript.Shell")
        wsh$SendKeys("\014")
        invisible(wsh)
}
cls()  # invoke



On 2/17/06, Marcus Leinweber <[hidden email]> wrote:

> have already tried this?
>
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/55752.html
>
> m.
>
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of Michael
> > Sent: Thursday, February 16, 2006 9:23 PM
> > To: Henrik Bengtsson
> > Cc: [hidden email]
> > Subject: Re: [R] how to clear screen in R-console?
> >
> > I am actually using Rgui on Windows...
> >
> > What can I do?
> >
> > There is no way to programmatically clear screen?
> >
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Gabor Grothendieck
Here is a version that uses rcom instead of RDCOMClient.
This has the advantage that rcom is on CRAN.

cls <- function() {
        require(rcom)
        wsh <- comCreateObject("Wscript.Shell")
        comInvoke(wsh, "SendKeys", "\014")
        invisible(wsh)
}
cls() # test

On 2/17/06, Gabor Grothendieck <[hidden email]> wrote:

> Here is a translation of Norm Olsen's vbscript code into pure R.
> This is intended for use with the Windows Rgui interface.
>
> cls <- function() {
>        require(RDCOMClient)
>        wsh <- COMCreate("Wscript.Shell")
>        wsh$SendKeys("\014")
>        invisible(wsh)
> }
> cls()  # invoke
>
>
>
> On 2/17/06, Marcus Leinweber <[hidden email]> wrote:
> > have already tried this?
> >
> > http://finzi.psych.upenn.edu/R/Rhelp02a/archive/55752.html
> >
> > m.
> >
> >
> > > -----Original Message-----
> > > From: [hidden email]
> > > [mailto:[hidden email]] On Behalf Of Michael
> > > Sent: Thursday, February 16, 2006 9:23 PM
> > > To: Henrik Bengtsson
> > > Cc: [hidden email]
> > > Subject: Re: [R] how to clear screen in R-console?
> > >
> > > I am actually using Rgui on Windows...
> > >
> > > What can I do?
> > >
> > > There is no way to programmatically clear screen?
> > >
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Paul Roebuck
In reply to this post by Henrik Bengtsson-2
On Thu, 16 Feb 2006, Henrik Bengtsson wrote:

> On 2/16/06, Michael <[hidden email]> wrote:
>
> > On 2/16/06, Christian Schulz <[hidden email]> 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)

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to clear screen in R-console?

Philippe Grosjean
In reply to this post by Gabor Grothendieck
And here is a reworked version that checks if it is RGui, if WSH is
started, etc. and that returns invisibly TRUE/FALSE:

# An R function to clear the screen on RGui:
cls <- function() {
        if (.Platform$GUI[1] != "Rgui")
                return(invisible(FALSE))
        if (!require(rcom, quietly = TRUE)) # Not shown any way!
                stop("Package rcom is required for 'cls()'")
        wsh <- comCreateObject("Wscript.Shell")
        if (is.null(wsh)) {
                return(invisible(FALSE))
        } else {
                comInvoke(wsh, "SendKeys", "\014")
                return(invisible(TRUE))
        }
}
#cls() # test
# If you want to make sure that it worked (well, not 100% sure, but...)
res <- cls()
if (res) cat("Console should be cleared now!\n")

Best,

Philippe Grosjean

P.S.: Gabor, I would like to include this function in the SciViews
bundle. Would it be a problem for you?

..............................................<°}))><........
  ) ) ) ) )
( ( ( ( (    Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (    Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Pentagone (3D08)
( ( ( ( (    Academie Universitaire Wallonie-Bruxelles
  ) ) ) ) )   8, av du Champ de Mars, 7000 Mons, Belgium
( ( ( ( (
  ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
( ( ( ( (    email: [hidden email]
  ) ) ) ) )
( ( ( ( (    web:   http://www.umh.ac.be/~econum
  ) ) ) ) )          http://www.sciviews.org
( ( ( ( (
..............................................................

Gabor Grothendieck wrote:

> Here is a version that uses rcom instead of RDCOMClient.
> This has the advantage that rcom is on CRAN.
>
> cls <- function() {
> require(rcom)
> wsh <- comCreateObject("Wscript.Shell")
> comInvoke(wsh, "SendKeys", "\014")
> invisible(wsh)
> }
> cls() # test
>
> On 2/17/06, Gabor Grothendieck <[hidden email]> wrote:
>
>>Here is a translation of Norm Olsen's vbscript code into pure R.
>>This is intended for use with the Windows Rgui interface.
>>
>>cls <- function() {
>>       require(RDCOMClient)
>>       wsh <- COMCreate("Wscript.Shell")
>>       wsh$SendKeys("\014")
>>       invisible(wsh)
>>}
>>cls()  # invoke
>>
>>
>>
>>On 2/17/06, Marcus Leinweber <[hidden email]> wrote:
>>
>>>have already tried this?
>>>
>>>http://finzi.psych.upenn.edu/R/Rhelp02a/archive/55752.html
>>>
>>>m.
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: [hidden email]
>>>>[mailto:[hidden email]] On Behalf Of Michael
>>>>Sent: Thursday, February 16, 2006 9:23 PM
>>>>To: Henrik Bengtsson
>>>>Cc: [hidden email]
>>>>Subject: Re: [R] how to clear screen in R-console?
>>>>
>>>>I am actually using Rgui on Windows...
>>>>
>>>>What can I do?
>>>>
>>>>There is no way to programmatically clear screen?
>>>>
>>>
>>>______________________________________________
>>>[hidden email] mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>>
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Loading...