Ken Knoblauch
2009-Jun-16 12:24 UTC
[R] overshoot of formula line in summary output of Sweave
Hi, In the Sweave output for summary for several types of model objects and also for the comparison of models with anova, I find that that the display of the call(s) or formula does not obey the width option, even with keep.source=TRUE set, so that a long formula will overshoot the margins in the document. I would like to know if there is a good way to correct that. Looking at the print.summary methods for lm, glm and several others, I see that a construct like deparse(obj$call) is used to generate the text. The deparse function takes a "width.cutoff" argument, that could be used in these cases, if it were possible to pass a value to it, or if its default value could be set with an option. Other methods do not use deparse, (print.summary.polr in MASS uses dput and anovalist.nls also does it differently) so such a solution would not work universally without altering these functions. Here is a toy example that illustrates the overshoot of the formula \documentclass[12pt]{article} \usepackage{geometry} \geometry{left=2in,right=2in} \begin{document} <<keep.source=TRUE>>op <- options(width = 65, digits = 3) ddataframe <- data.frame(AAAAA = 1:10, BBBBB = factor(letters[1:2]), CCCCC = factor(LETTERS[1:5]), SSSSS = factor(paste("S", 1:10, sep = "")), RRRRR = rnorm(10)) mod1 <- lm(RRRRR ~ AAAAA + BBBBB + CCCCC + SSSSS, ddataframe) summary(mod1) @ \end{document} I have attached the pdf output. Thanks, in advance, for any suggestions. Ken -- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen L?pine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: TmpTest.pdf Type: application/pdf Size: 24761 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090616/54f760b2/attachment-0002.pdf>
Ben Bolker
2009-Jun-17 21:53 UTC
[R] overshoot of formula line in summary output of Sweave
Ken Knoblauch wrote:> > Hi, > > In the Sweave output for summary for several types > of model objects and also for the comparison of models > with anova, I find that that the display of the call(s) > or formula does not obey the width option, even with > keep.source=TRUE set, so that a long formula will overshoot > the margins in the document. I would like to know if > there is a good way to correct that. Looking at the > print.summary methods for lm, glm and several others, > I see that a construct like deparse(obj$call) is used > to generate the text. The deparse function takes a > "width.cutoff" argument, that could be used in these cases, > if it were possible to pass a value to it, or if its default > value could be set with an option. Other methods do not > use deparse, (print.summary.polr in MASS uses dput and > anovalist.nls also does it differently) so such a solution > would not work universally without altering these functions. > > Here is a toy example that illustrates the overshoot of the formula > > \documentclass[12pt]{article} > \usepackage{geometry} > \geometry{left=2in,right=2in} > \begin{document} > <<keep.source=TRUE>>> op <- options(width = 65, digits = 3) > ddataframe <- data.frame(AAAAA = 1:10, > BBBBB = factor(letters[1:2]), > CCCCC = factor(LETTERS[1:5]), > SSSSS = factor(paste("S", 1:10, sep = "")), > RRRRR = rnorm(10)) > > mod1 <- lm(RRRRR ~ AAAAA + BBBBB + CCCCC + SSSSS, > ddataframe) > summary(mod1) > @ > \end{document} > > I have attached the pdf output. > > Thanks, in advance, for any suggestions. > > Ken > > >A quick guess: try keep.source=TRUE and format your commands as you would like to see them appear ... Ben Bolker -- View this message in context: http://www.nabble.com/overshoot-of-formula-line-in-summary-output-of-Sweave-tp24053269p24082795.html Sent from the R help mailing list archive at Nabble.com.