[R] Sweave trim output
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Fri Feb 25 09:10:23 CET 2011
Dear All,
I'd like to trim the output produced in a Sweave code chunk. For
instance, in
fit <- lm(conc ~ . - Plant, data = CO2)
summary(fit)
I'd like, skip the info after the coefficients' table, and possibly
replace it with '...'.
I've created this small function to do this, which is based on
capture.output():
trim.output <- function (x, lines, above = FALSE) {
if (above)
cat("\n...\n\n")
cat(paste(x[lines], collapse = "\n"))
cat("\n\n...\n")
}
out <- capture.output(summary(fit))
trim.output(out, 1:13)
but I was wondering if there is an *official* way to do this.
Thanks in advance.
Best,
Dimitris
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/
More information about the R-help
mailing list