[R] Page eject and clearing the console

Greg Snow Greg.Snow at imail.org
Tue Jan 4 21:33:20 CET 2011


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.).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of John Sorkin
> Sent: Tuesday, January 04, 2011 12:52 PM
> To: David Winsemius; Bert Gunter
> Cc: r-help at r-project.org
> Subject: Re: [R] Page eject and clearing the console
> 
> 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:
> >
> > On Jan 4, 2011, at 1:27 PM, David Winsemius wrote:
> >
> >>
> >> On Jan 4, 2011, at 1:19 PM, John Sorkin 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?
> >>
> >> "\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.)
> >>
> >
> > 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.
> >>
> >>
> >>> 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:
> >>>
> >>>> (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\...{{dropped:25}}
> >>>
> >>> ______________________________________________
> >>> R-help at r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> >>> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>
> >> David Winsemius, MD
> >> West Hartford, CT
> >>
> >> ______________________________________________
> >> R-help at r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > David Winsemius, MD
> > West Hartford, CT
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> --
> Bert Gunter
> Genentech Nonclinical Biostatistics
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> Confidentiality Statement:
> This email message, including any attachments, is for
> th...{{dropped:6}}
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list