[R] writing summary() to a text file

2007-11-26 Thread Federico Calboli
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@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.


Re: [R] writing summary() to a text file

2007-11-26 Thread John Kane
Would something like this do it?

sink(file=reg.txt)
summary(reg)
sink()

--- Federico Calboli [EMAIL PROTECTED] 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@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@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.


Re: [R] writing summary() to a text file

2007-11-26 Thread jim holtman
?capture.output

On Nov 26, 2007 9:31 AM, Federico Calboli [EMAIL PROTECTED] 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@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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@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.


Re: [R] writing summary() to a text file

2007-11-26 Thread Richard . Cotton
 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))

You can either redirect output to a file using cat or sink; generate a 
latex table using xtable (in the xtable package); or export the relevant 
bits (e.g. the coefficients matrix) using write.csv.

Based upon your message, sink is probably your best bet/

sink(file=foo.txt)
summary(lm(x ~ y + w * z))
sink(NULL)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
R-help@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.


Re: [R] writing summary() to a text file

2007-11-26 Thread Gabor Grothendieck
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 [EMAIL PROTECTED] wrote:
 Would something like this do it?

 sink(file=reg.txt)
 summary(reg)
 sink()


 --- Federico Calboli [EMAIL PROTECTED] 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@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@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.


__
R-help@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.


Re: [R] writing summary() to a text file

2007-11-26 Thread Mike Prager
Federico Calboli [EMAIL PROTECTED] wrote:

 
 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:
 

Take a look at the sink() function.  Does that do what you need?

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

__
R-help@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.