[R] more or less pager

Gabor Grothendieck ggrothendieck at myway.com
Sat Feb 7 03:20:52 CET 2004



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




More information about the R-help mailing list