[R] options()$width ignored by print.formula

Sarah Goslee sarah.goslee at gmail.com
Tue Nov 6 18:01:35 CET 2012


Hi all,

I'm working with summary.gam() and noticed that the options()$width
argument is ignored by some components of that function, in particular
the formula, which is printed at an arbitrary length regardless of the
desired width.

I've tracked the problem back to print.formula(), so at a lower level
than summary.gam(). Is there a way around this that I'm missing?

library(mgcv)
# start with example from ?gam
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)


colnames(dat)[1:5] <- c("reallylongnamey", "reallylongnamex0",
"reallylongnamex1", "reallylongnamex2", "reallylongnamex3")
b <- gam(reallylongnamey~s(reallylongnamex0)+s(reallylongnamex1)+s(reallylongnamex2)+s(reallylongnamex3),data=dat)

options(width=20)
b$formula # not wrapped to 20 characters

options(width=150)
b$formula # the formula is wrapped even though it fits in the specified width

# also true for lm()
b <- lm(reallylongnamey~reallylongnamex0+reallylongnamex1+reallylongnamex2+reallylongnamex3,data=dat)

options(width=20)
b$call

options(width=150)
b$call


Thanks,
Sarah

--
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list