[R] Sweave and abbreviating output from R

Gabor Grothendieck ggrothendieck at gmail.com
Mon Apr 11 13:34:28 CEST 2005


On Apr 11, 2005 7:22 AM, Gavin Simpson <gavin.simpson at ucl.ac.uk> wrote:
> 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?
> 

Maybe you could use head(rnorm(100)) instead.  Check ?head
for other arguments.




More information about the R-help mailing list