Michael Just
2008-Sep-24 17:45 UTC
[R] Add "title" in sink output and possibility of plot-like output for text
Hello, I have been using sink to create text file outputs.>sink("summ_model1and2.txt") > summary(model1) > summary(model2) > sink()Q1: Is there a way I could add a line of the text above the summary to act like a title? Also, I have been using the following to save plots from the lm function:> pdf("small.bin.ENN_MN_withQ.pdf") > par(mfrow = c(2, 2), oma = c(0, 0, 2, 0)) > plot(small.bin.ENN_MN) > plot(small.bin.ENN_MN.q) > dev.off()Q2: Is there a way I could save the output from 'summary' into a c(2,2) window like I do with the plots? Thank you kindly, Cheers, M Just [[alternative HTML version deleted]]
Greg Snow
2008-Sep-24 19:47 UTC
[R] Add "title" in sink output and possibility of plot-like output for text
You could use the cat function to output some text that would then be included in the sinked output file. Or look at the txtStart and related functions in the TeachingDemos package for an alternative to sink that can include the code interspersed with the output and add additional text using txtComment. You can even include graphs and some markup if willing to do a little postprocessing. Look at the textplot function in the gplots package for one way to include the results from summary in one frame of a plot. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Michael Just > Sent: Wednesday, September 24, 2008 11:46 AM > To: r-help at r-project.org > Subject: [R] Add "title" in sink output and possibility of plot-like > output for text > > Hello, > I have been using sink to create text file outputs. > > >sink("summ_model1and2.txt") > > summary(model1) > > summary(model2) > > sink() > > Q1: Is there a way I could add a line of the text above the summary to > act > like a title? > > Also, I have been using the following to save plots from the lm > function: > > > pdf("small.bin.ENN_MN_withQ.pdf") > > par(mfrow = c(2, 2), oma = c(0, 0, 2, 0)) > > plot(small.bin.ENN_MN) > > plot(small.bin.ENN_MN.q) > > dev.off() > > Q2: Is there a way I could save the output from 'summary' into a c(2,2) > window like I do with the plots? > > Thank you kindly, > Cheers, > M Just > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.
Jorge Ivan Velez
2008-Sep-24 19:57 UTC
[R] Add "title" in sink output and possibility of plot-like output for text
Dear Michael, For your first question, something like this should work: sink("summ_model1and2.txt") cat('Summary model1','\n','\n') summary(model1) cat('\n','\n') cat('Summary model2','\n','\n') summary(model2) sink() For the second one, ?savePlot could work. HTH, Jorge On Wed, Sep 24, 2008 at 1:45 PM, Michael Just <mgjust@gmail.com> wrote:> Hello, > I have been using sink to create text file outputs. > > >sink("summ_model1and2.txt") > > summary(model1) > > summary(model2) > > sink() > > Q1: Is there a way I could add a line of the text above the summary to act > like a title? > > Also, I have been using the following to save plots from the lm function: > > > pdf("small.bin.ENN_MN_withQ.pdf") > > par(mfrow = c(2, 2), oma = c(0, 0, 2, 0)) > > plot(small.bin.ENN_MN) > > plot(small.bin.ENN_MN.q) > > dev.off() > > Q2: Is there a way I could save the output from 'summary' into a c(2,2) > window like I do with the plots? > > Thank you kindly, > Cheers, > M Just > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >[[alternative HTML version deleted]]