[R] writing summary() to a text file

Gabor Grothendieck ggrothendieck at gmail.com
Mon Nov 26 16:18:01 CET 2007


Also, this works:

s <- summary(iris)
capture.output(s, file = "myfile.txt")

and the Hmisc and xtable packages can output it in latex:

library(xtable)
print(xtable(s), file = "myfile.tex")

library(Hmisc)
latex(s, file= "myfile.tex")

On Nov 26, 2007 9:59 AM, John Kane <jrkrideau at yahoo.ca> wrote:
> Would something like this do it?
>
> sink(file="reg.txt")
> summary(reg)
> sink()
>
>
> --- Federico Calboli <f.calboli at imperial.ac.uk> wrote:
>
> > Hi All,
> >
> > I would like to output the results of a function
> > into a text file,
> > legible as a such. The function produces a summary
> > quite like:
> >
> > summary(lm(x ~ y + w * z))
> >
> > [for instance]
> >
> > and I am not clear how to save this summary into a
> > text file
> > 'automagically', because I need to be able to do it
> > in a for() loop.
> >
> > Cheers,
> >
> > Federico
> >
> > --
> > Federico C. F. Calboli
> > Department of Epidemiology and Public Health
> > Imperial College, St. Mary's Campus
> > Norfolk Place, London W2 1PG
> >
> > Tel +44 (0)20 75941602   Fax +44 (0)20 75943193
> >
> > f.calboli [.a.t] imperial.ac.uk
> > f.calboli [.a.t] gmail.com
> >
> > ______________________________________________
> > R-help at r-project.org 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.
> >
>
>
>
>      Looking for the perfect gift? Give the gift of Flickr!
>
> http://www.flickr.com/gift/
>
>
> ______________________________________________
> R-help at r-project.org 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.
>



More information about the R-help mailing list