[R] Redirecting print output

Stephen Tucker brown_emu at yahoo.com
Tue Jul 24 10:18:51 CEST 2007


Here are two simple ways:

=== method1 ===
cat("line1","\n",file="output.txt")
cat("line2","\n",file="output.txt",append=TRUE)

=== method2 ===
sink("output.txt")
cat("line1","\n")
cat("line2","\n")
out <- lm(y~x,data=data.frame(x=1:10,y=(1:10+rnorm(10,0,0.1))))
print(out)
sink()

And then there is 'Sweave'. Check out, for instance
<http://www.stat.umn.edu/~charlie/Sweave/>

You can embed R code, figures, and output from print methods into your latex
document.

ST
--- Stan Hopkins <stanhopkins at comcast.net> wrote:

> I see a rich set of graphic device functions to redirect that output.  Are
> there commands to redirect text as well.  I have a set of functions that
> execute many linear regression tests serially and I want to capture this in
> a file for printing.
> 
> Thanks,
> 
> Stan Hopkins
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



       
____________________________________________________________________________________Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV.



More information about the R-help mailing list