Re: [R] Question in R

From: John Fox <jfox_at_mcmaster.ca>
Date: Sat, 02 Feb 2008 10:15:20 -0500

NO

Dear Oliver,

I'm not sure why you'd want to do this rather than just scrolling the console after the output is completed (assuming, of course, that you can scroll your console), but here's a function (not extensively tested) that might do what you want:

more <- function(command, lines=20){
  output <- capture.output(eval(command, envir=.GlobalEnv))   outputlines <- length(output)
  screens <- ceiling(outputlines/lines)
  if (screens < 1) {
    return(invisible(NULL))
    }
  for (i in 1:screens){
    first <- (i - 1)*lines + 1
    last <- min(outputlines, i*lines)
    sapply(output[first:last], function(x) cat(x, "\n"))     if (i < screens){

      value <- readline("<Enter 'q' to quit, Enter to continue>")
      if (value == "q") break()
      }

    }
  invisible(NULL)
  }   

You'd use this as in more(cars), where you can substitute the command that you want for "cars".

I hope this helps,
 John

On Sat, 2 Feb 2008 13:21:15 +0100
 "Oliver Herbst" <oliverherbst_at_gmx.de> wrote:
> HI,
>
>
>
> can anybody help me how to observe or read the output of an r command
> pagewise? (E.g. to make a break after the first page of output data
> and then
> continue by putting a key on the console)
>
>
>
> Thanks a lot.
>
> Oliver
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

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. Received on Sat 02 Feb 2008 - 15:31:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 02 Feb 2008 - 16:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive