Skip to content

clear screen?

6 messages · Charles Annis, P.E., Daniel Viar, Duncan Murdoch +1 more

#
I?ve been using this routine for several years.  I?m sorry, I don?t remember
where I got it.  It works as it should, viz. it blanks the R console.  But
it requires package rcom and now that requires rscproxy.

cls <-
function () 
{
    require(rcom)
    wsh <- comCreateObject("Wscript.Shell")
    comInvoke(wsh, "SendKeys", "\f")
    invisible(wsh)
}
Loading required package: rcom
Loading required package: rscproxy

This seems like overkill to me just to blank the R console, especially since
I am trying to diminish the number of necessary packages to support my
home-brew package.

So, is there an easier way to blank the R console in Windows?
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] splines   tcltk     stats     graphics  grDevices utils     datasets
methods   base     

other attached packages:
[1] rcom_2.1-1         rscproxy_1.2-0     survival_2.35-3
RColorBrewer_1.0-2   RODBC_1.2-5       myhomebrew

loaded via a namespace (and not attached):
[1] tools_2.8.1
Charles Annis, P.E.

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:? 614-455-3265
http://www.StatisticalEngineering.com
?
#
You got it from my post here:
http://tolstoy.newcastle.edu.au/R/help/06/02/21556.html

Don't know why rcom's dependencies are a consideration
but RDCOMClient can also handle this:

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



On Sun, May 3, 2009 at 6:50 PM, Charles Annis, P.E.
<Charles.Annis at statisticalengineering.com> wrote:
#
Thank you Gabor.  I'm sorry I forgot whom to acknowledge as the author.

My (limited) understanding is that rcom with rscproxy essentially give the R
session the ability to look like a server, and that this scares some who are
concerned with security issues.  I don't want any more capability than
necessary and thus wanted something less potent to clear the console.

Thanks for the insight.

Charles Annis, P.E.

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] 
Sent: Sunday, May 03, 2009 7:31 PM
To: Charles.Annis at statisticalengineering.com
Cc: r-help at r-project.org
Subject: Re: [R] clear screen?

You got it from my post here:
http://tolstoy.newcastle.edu.au/R/help/06/02/21556.html

Don't know why rcom's dependencies are a consideration
but RDCOMClient can also handle this:

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



On Sun, May 3, 2009 at 6:50 PM, Charles Annis, P.E.
<Charles.Annis at statisticalengineering.com> wrote:
remember
since
http://www.R-project.org/posting-guide.html
#
I'm not sure how to put it in a function (or if this helps), but
Ctrl+L will clear the R Console in Windows.

Cheers,
Dan Viar


On Sun, May 3, 2009 at 6:58 PM, Charles Annis, P.E.
<Charles.Annis at statisticalengineering.com> wrote:
#
On 03/05/2009 6:50 PM, Charles Annis, P.E. wrote:
Ctrl-L will do it.  If you want to put it in a function, I don't think so.

An item that has been on my wish list for a long time is to rewrite the 
menu system in the Windows gui so that all items can be invoked from R 
code.  It's been sitting there in the section entitled "I wish someone 
else would do this."  It would not be hard, but it would be a lot of 
tedious work.

Duncan Murdoch
#
On Mon, May 4, 2009 at 6:50 AM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
Note that the same technique used to clear the screen could be used for
this as well. For example, this causes the FAQ to appear by sending
the appropriate set of characters to active the menu:

sendKeys <- function (x) {
	require(RDCOMClient)
	wsh <- COMCreate("Wscript.Shell")
	wsh$SendKeys(x)
	invisible(wsh)
}
faq <- function() sendKeys("%HF\n")

faq()

Might have to add some Sys.sleep calls to slow it down but so far it
seems to work for me.