[R] update.formula has 512 char buffer?

Duncan Murdoch murdoch.duncan at gmail.com
Tue Feb 28 21:28:01 CET 2012


On 28/02/2012 2:46 PM, Bert Gunter wrote:
> Your code seems to be screwed up. There are no (small) size
> limitations on formulas (afaik).
>
> The following worked fine for me:
>
> x<- paste("x",1:100,sep="",collapse = " + ")
> part1<- paste("y",x,sep=" ~ ")
> part2<- paste("f",1:50, sep="",collapse = " + ")
> fml<- formula(paste(part1,part2,sep=" | "))

I think the problem is in R, not in what Chris did.  It seems to be in 
update.formula, or terms.formula, or some related function.

I'll try to track it down.

Duncan

> Cheers,
> Bert
>
> On Tue, Feb 28, 2012 at 11:11 AM, Chris Hane
> <christopher.a.hane at gmail.com>  wrote:
> >  Hello,
> >
> >  I am trying to "paste" together a formula to use in the mob function of
> >  party. This means the formula will be of the form y ~ x1+ ...+xM | z1+..zN.
> >
> >  I am doing some preliminary fits of y ~ x1+ ...+xM, then want to add the
> >  conditional part of the equation using update().
> >
> >  Here's the test code:
> >  var1<- 1:78
> >  x1<- paste("x", var1, sep="")
> >  f1<- paste("f", var1[1:10], sep="")
> >
> >  # use first 77 variables
> >  fmla<- as.formula( paste("y ~ ", paste(x1[1:77], collapse=" + ", sep=""),
> >  sep=""))
> >  fmla2<- update(fmla, paste(". ~ . | ", paste(f1, collapse= " + "), sep=""))
> >
> >  # CHANGE x to all 78 variables
> >  fmla<- as.formula( paste("y ~ ", paste(x1, collapse=" + ", sep=""),
> >  sep=""))
> >  fmla2<- update(fmla, paste(". ~ . | ", paste(f1, collapse= " + "), sep=""))
> >
> >  I have run this in Windows and Linux (64 bit) and both fail when using all
> >  78 terms (and anything more than 78 terms). The error message contains
> >  Error in parse(text = x) : :1:514: unexpected ')'.
> >
> >  Changing the length of the names of the x variables will break the update()
> >  with fewer variables, but always with an error referring to just more than
> >  512 characters.  There is nothing special about 77 or 78 variables here; I
> >  want to do this with hundreds of variables.
> >
> >  Is there a workaround to this?
> >
> >          [[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.
>
>
>



More information about the R-help mailing list