Skip to content

Page eject and clearing the console

9 messages · Henrique Dallazuanna, Sarah Goslee, John Sorkin +3 more

#
(1) I know that \n when used in cat, e.g. cat("\n") produces a line feed (i.e. skips to the next line). Is there any escape sequence that will go to the top of the next page?
(2) I know that control L will clear the console. Is there an equivalent function or other means that can be used in R code to clear the console?

Thanks,
John  


John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}
#
Hi John,

I don't understand what you mean by "top of the next page", or rather,
how that differs from clearing the screen.

And for the latter, that is dependent on OS, and on GUI/console usage,
and has been discussed several times on the list. The easiest solution
is to invoke the system command if running in a console. For linux,
that would be:
system("clear")

A Google search using the exact words from your question found several
more options, including a discussion of doing this in Windows.
http://www.google.com/search?q=R+code+to+clear+the+console

I can't test them for you, but since I don't know if you're using Windows
or not it may not matter.

Sarah


On Tue, Jan 4, 2011 at 11:54 AM, John Sorkin
<jsorkin at grecc.umaryland.edu> wrote:

  
    
#
I have received help on one of my questions (thank you Henrique Jorge
and ), viz. how I can clear the console from an R program. 
I have not yet received help on how I can skip to the top of the next
page, i.e. cat("\n") skips to the next line, is there an equivalent way
to skip to the top of the next page?
Thanks,
John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)>>>
Henrique Dallazuanna <wwwhsd at gmail.com> 1/4/2011 11:58 AM >>>
Take a look on:
http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html 

On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin
<jsorkin at grecc.umaryland.edu>wrote:

            
feed
go to
equivalent
console?
#
On Jan 4, 2011, at 1:19 PM, John Sorkin wrote:

            
"\n" does NOT "skip to the next line". It is a character and it is  
interpreted by some sort of program, say a a plotting program or a  
word-processor as a line feed. You need to specify what sort of  
program you intend to do this "skipping-to-next-page" action and also  
provide the character sequence that that program uses to signal that  
action. (There are not any pages in R except perhaps multi-page plots  
but you seem to be in character mode at the moment.)
#
On Jan 4, 2011, at 1:27 PM, David Winsemius wrote:

            
It has occurred to me that you may be asking for something that will  
give the illusion of "clearing the screen" but will in fact be just  
"printing" a page of blank space on a console display, scrolling would  
ahve been the name I would have given it. In which case:

scroll <- function(lines=40) cat(rep("\n", lines))
scroll()
David Winsemius, MD
West Hartford, CT
#
Perhaps merely rephrasing David's comments,

"page" is not a meaningful physical entity -- it depends on font size,
line spacing, etc. and the physical "size" of the output surface,
which has no meaning for an "infinitely" (or at least up to tyhe
screen buffer's limit) scrollable screen viewing area.

But maybe David's "scroll" function is what you had in mind.

-- Bert
On Tue, Jan 4, 2011 at 10:55 AM, David Winsemius <dwinsemius at comcast.net> wrote:

  
    
#
I am looking for something which will emulate the following:
Back in the old days, when printing to a line printer, the first two characters in a line controlled printing. For example, a line starting with 
1h1 starts printing at the top of the next page.
1h+ indicates overprinting
1h0 results in double 
In R "\n" skips to the next line. Is there some escape sequence that will start printing at the top of the next page?
Thanks,
John





John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)>>> Bert Gunter <gunter.berton at gene.com> 1/4/2011 2:05 PM >>>
Perhaps merely rephrasing David's comments,

"page" is not a meaningful physical entity -- it depends on font size,
line spacing, etc. and the physical "size" of the output surface,
which has no meaning for an "infinitely" (or at least up to tyhe
screen buffer's limit) scrollable screen viewing area.

But maybe David's "scroll" function is what you had in mind.

-- Bert
On Tue, Jan 4, 2011 at 10:55 AM, David Winsemius <dwinsemius at comcast.net> wrote:

  
    
#
Well the things most like cat('\n') for starting a new page would be cat('\013') or cat('\014') (vertical tab and form feed), however on all the terminals I tried they don't do anything since page is not a concept on a terminal.  However if you outputted one of those into a file and interpreted the file in a context with pages, then they may do what you want.

The next closest idea to what you are saying that I can find is the wdPageBreak function in the R2wd package.  This will insert a page break into a word document that is being created from R, there pages make sense and this will start the next part on a new page.

To be any more help we need to know what context you are using this in and what you mean by "page".  Are you preparing stuff to be printed on paper (or at least to a pdf doc where pages make sense?) or is there some behavior in the terminal that you want to see?  For the last we need to know OS and possibly how you are running R within that OS (gui vs. terminal, etc.).