R-users, (forgive my return adres) I've been breaking my head why R---which i find fabulous, by the way---does not pipe interactive output through a pager (more or less), like it does with help(), or like GNU Octave does with arrays with more than terminal height rows. Maybe it is my installation (Debian/GNU Linux). Maybe it is my configuration, but i don't think so because with help() it works ## Default pager PAGER=${PAGER-'/usr/bin/less'} But i think it really is because R-users apparently don't look at dataframes with more than, say, 24 rows. I always seem to be intetrested in column names with some rows of data, so often I type > data[1,] just to see what the columns were called again. In order to circumvent the problem of data running off the screen, I've made a simple hack: more <- function(x) { tmp <- paste("/tmp/R", floor(runif(1,0,1e6)), sep=".") sink(tmp) print(x) sink() file.show(tmp, delete.file=TRUE) } which isn't the prettiest implementation of `tmpfile', but hey, it allows my to type > more(data) Please ignore this if there is a more proper way of doing this in R (preferrably by default without the more()), but also please include some reference to this under keywords `pager', `more' or `less' in the documentation. Developers, thanks for all the work. -- David A. van Leeuwen < @ElseWare.nl> Echt stijlvol sterven doe je / bij een ander op de mat Op de dag dat je bezorgd wordt / door het NRC Handelsblad ---Joop Visser
David, try fix() or names() with your dataframe (to view column names + data and column names, respectively). STS -----Original Message----- From: David A. van Leeuwen [mailto:davl-s0p0a0m at cistron.nl] Sent: Friday, February 06, 2004 10:07 AM To: r-help at stat.math.ethz.ch Subject: [R] more or less pager R-users, (forgive my return adres) I've been breaking my head why R---which i find fabulous, by the way---does not pipe interactive output through a pager (more or less), like it does with help(), or like GNU Octave does with arrays with more than terminal height rows. Maybe it is my installation (Debian/GNU Linux). Maybe it is my configuration, but i don't think so because with help() it works ## Default pager PAGER=${PAGER-'/usr/bin/less'} But i think it really is because R-users apparently don't look at dataframes with more than, say, 24 rows. I always seem to be intetrested in column names with some rows of data, so often I type > data[1,] just to see what the columns were called again. In order to circumvent the problem of data running off the screen, I've made a simple hack: more <- function(x) { tmp <- paste("/tmp/R", floor(runif(1,0,1e6)), sep=".") sink(tmp) print(x) sink() file.show(tmp, delete.file=TRUE) } which isn't the prettiest implementation of `tmpfile', but hey, it allows my to type > more(data) Please ignore this if there is a more proper way of doing this in R (preferrably by default without the more()), but also please include some reference to this under keywords `pager', `more' or `less' in the documentation. Developers, thanks for all the work. -- David A. van Leeuwen < @ElseWare.nl> Echt stijlvol sterven doe je / bij een ander op de mat Op de dag dat je bezorgd wordt / door het NRC Handelsblad ---Joop Visser ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Fri, Feb 06, 2004 at 04:07:18PM +0100, David A. van Leeuwen wrote:> R-users, > > (forgive my return adres) > > I've been breaking my head why R---which i find fabulous, by the > way---does not pipe interactive output through a pager (more or less), > like it does with help(), or like GNU Octave does with arrays with more > than terminal height rows. > > Maybe it is my installation (Debian/GNU Linux). Maybe it is my > configuration, but i don't think so because with help() it works > > ## Default pager > PAGER=${PAGER-'/usr/bin/less'}[ Future Debian R packages will have this default to PAGER-'/usr/bin/pager' which is handled by the dpkg-alternatives mechanism; this helps e.g. users in the Far East who use jless or jv; and everybody else who may prefer most or one of the other pagers. This follows a wishlist request I had for octave2.1, and which also makes sense for R. Can't help you with the more R-internal request of paging wider than 80col, other than with the default answer to just about every UI question: use ESS as you then get the benefit if (x)emacs buffers around your session. Plus much much more. It is really worth it, and on Debian only the few keystrokes of 'apt-get install ess' away. ]> But i think it really is because R-users apparently don't look at > dataframes with more than, say, 24 rows. I always seem to be intetrested > in column names with some rows of data, so often I type > > > data[1,] > > just to see what the columns were called again. > > In order to circumvent the problem of data running off the screen, I've > made a simple hack: > > more <- function(x) { > tmp <- paste("/tmp/R", floor(runif(1,0,1e6)), sep=".") > sink(tmp) > print(x) > sink() > file.show(tmp, delete.file=TRUE) > } > > which isn't the prettiest implementation of `tmpfile', but hey, it > allows my to type > > > more(data)Not bad. But then again, there is ESS :) Dirk> > Please ignore this if there is a more proper way of doing this in R > (preferrably by default without the more()), but also please include > some reference to this under keywords `pager', `more' or `less' in the > documentation. > > Developers, thanks for all the work. > > -- > David A. van Leeuwen < @ElseWare.nl> > > Echt stijlvol sterven doe je / bij een ander op de mat > Op de dag dat je bezorgd wordt / door het NRC Handelsblad > > ---Joop Visser > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >-- The relationship between the computed price and reality is as yet unknown. -- From the pac(8) manual page
On 06-Feb-04 David A. van Leeuwen wrote:>## Default pager > PAGER=${PAGER-'/usr/bin/less'} > > But i think it really is because R-users apparently don't look at > dataframes with more than, say, 24 rows. I always seem to be > intetrested in column names with some rows of data, so often I type > > > data[1,] > > just to see what the columns were called again.I don't think there's a way of getting long output from a raw command (which "data[1,]" is) to be paged in an interactive terminal (though I stand to be corrected and would be interested in the details if I am wrong). If the output is not too long, the scroll bar on the xterm running R (or Shift-PgUp/Shift-PgDn) will allow you to look at what has scrolled up off the screen.> In order to circumvent the problem of data running off the screen, I've > made a simple hack: > > more <- function(x) { > ... > } > > which isn't the prettiest implementation of `tmpfile', but hey, it > allows my to type > > > more(data)Since [above] your default pager is 'less', you can do page(data) without defining a new function for it. See "?page". (Here, "data" is no longer a "raw command" since it is wrapped in "page"). You may also be interested in the following, which I owe to helpful people on the R list. In my ~/.Rprofile I have the following lines: .xthelp <- function() { tdir <- tempdir() pgr <- paste(tdir, "/pgr", sep="") con <- file(pgr, "w") cat("#! /bin/bash\n", file=con) cat("export HLPFIL=`mktemp ", tdir, "/R_hlp.XXXXXX`\n", sep="", file=con) cat("cat > $HLPFIL\nxterm -e less $HLPFIL &\n", file=con) close(con) system(paste("chmod 755 ", pgr, sep="")) options(pager=pgr) } .xthelp() rm(.xthelp) After these have been read in and executed at R startup, the command page(data) will open a separate xterm window in which the output from "data" will be displayed via 'less'. The same applies if you look up something R-ish using the "?" help command and the "help.search" command. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 06-Feb-04 Time: 19:58:56 ------------------------------ XFMail ------------------------------
str() is also useful. --- Date: Fri, 6 Feb 2004 12:05:50 -0500 From: Steve Sullivan <ssullivan at qedgroupllc.com> [ Add to Address Book | Block Address | Report as Spam ] To: <r-help at stat.math.ethz.ch> Subject: RE: [R] more or less pager David, try fix() or names() with your dataframe (to view column names + data and column names, respectively). STS -----Original Message----- From: David A. van Leeuwen [mailto:davl-s0p0a0m at cistron.nl] Sent: Friday, February 06, 2004 10:07 AM To: r-help at stat.math.ethz.ch Subject: [R] more or less pager R-users, (forgive my return adres) I've been breaking my head why R---which i find fabulous, by the way---does not pipe interactive output through a pager (more or less), like it does with help(), or like GNU Octave does with arrays with more than terminal height rows. Maybe it is my installation (Debian/GNU Linux). Maybe it is my configuration, but i don't think so because with help() it works ## Default pager PAGER=${PAGER-'/usr/bin/less'} But i think it really is because R-users apparently don't look at dataframes with more than, say, 24 rows. I always seem to be intetrested in column names with some rows of data, so often I type> data[1,]just to see what the columns were called again. In order to circumvent the problem of data running off the screen, I've made a simple hack: more <- function(x) { tmp <- paste("/tmp/R", floor(runif(1,0,1e6)), sep=".") sink(tmp) print(x) sink() file.show(tmp, delete.file=TRUE) } which isn't the prettiest implementation of `tmpfile', but hey, it allows my to type> more(data)Please ignore this if there is a more proper way of doing this in R (preferrably by default without the more()), but also please include some reference to this under keywords `pager', `more' or `less' in the documentation. Developers, thanks for all the work. -- David A. van Leeuwen < @ElseWare.nl> Echt stijlvol sterven doe je / bij een ander op de mat Op de dag dat je bezorgd wordt / door het NRC Handelsblad ---Joop Visser