Skip to content
Prev 67402 / 398506 Next

Sweave and abbreviating output from R

Gabor Grothendieck wrote:
<snip>
Thanks for this Gabor. Head/tail works just fine for my rnorm example, 
but for printed output from summary methods for example it doesn't quite 
work as I would like.

But that got me thinking a bit more and I remembered capture.output() 
and I saw that noquote() is used in head.function(). So, I can now get 
this far:

noquote(capture.output(summary(pondsca)))[1:10]
  [1] 

  [2] Call: 

  [3] 

  [4] Partitioning of mean squared contingency coefficient: 

  [5] 

  [6] Total         4.996 

  [7] Unconstrained 4.996 

  [8] 

  [9] Eigenvalues, and their contribution to the mean squared 
contingency coefficient
[10] 


Now all I need is to find out how to print without the indices 
[1],[2]...[n] being printed?

Also, I noticed that with some objects, more than one "line" of output 
is printed per line - just like a vector would. In the example below we 
see 3 "lines" of output printed per row.

x <- rnorm(100)
y <- rnorm(100)
noquote(capture.output(summary(lm(x ~ y))))[1:5]
[1]                     Call:               lm(formula = x ~ y)
[4]                     Residuals:

Is there a way to print only a single element of a vector per line?

Thanks in advance.

Gav