[R] Sweave and abbreviating output from R

Gavin Simpson gavin.simpson at ucl.ac.uk
Mon Apr 11 13:22:38 CEST 2005


Dear List,

I'm using Sweave to produce a series of class handouts for a course I am 
running. The students in previous years have commented about wanting 
output within the handouts so they can see what to expect the output to 
look like. So Sweave is a godsend for producing this type of handout - 
with one exception: Is there a way to suppress some rows of printed 
output so as to save space in the printed documentation? E.g

rnorm(100)

produces about 20 lines of output (depending on options("width")). I'd 
prefer something like:

rnorm(100)
   [1]  0.527739021  0.185551107 -1.239195562  0.020991608 -1.225632520
   [6] -1.000243373 -0.020180393  2.552180776 -1.719061533 -0.195024625
...
   [96] -0.744916379  0.863733400 -0.186667848  1.378236663 -0.499201046

The actual application would be printing of output from summary() 
methods. Ideally it would be nice to ask for line 1-10, 30-40, 100-102, 
for example, so you could print the first few lines of several sections 
of output. I'd like to automate this so I don't need to keep copying and 
pasting into the final tex source or forget to do it if I alter some 
previous part of the Sweave source.

Has anyone tried to do this? Does anyone know of an automatic way of 
achieving the simple abbreviation or the more complicated version I 
described?

Any thoughts on this?

Thanks in advance,

Gav
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [T] +44 (0)20 7679 5522
ENSIS Research Fellow             [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC                 [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list