[R] limited formula length in tsls

Zsombor Cseres-Gergely uctpzcs at ucl.ac.uk
Thu Aug 23 12:06:26 CEST 2001


On Thu, Aug 23, 2001 at 07:53:59AM +0100, Prof Brian D Ripley wrote:
> 
> The `tsls package' had me confused ...

Sorry about this.

> > The reason that the original version manipulates (somewhat awkwardly) the
> > model and instrumental-variables formulas in character form to produce a
> > combined formula to insure that missing data is treated consistently

So I guess the answer to my other question (what is the problem with my
workaround?) is that it does not comply with this requirement.


[snip]


> as.character is not the best tool for formulae.  Use deparse:
> 
> > deparse(mod)
> [1] "this ~ is + a + very + long + formula + with + a + very + large + "
> [2] "    number + of + characters"
> 
> say via
> 
> paste(deparse(mod, 500), collapse="")
> 
> which will cope with arbitrary long formulae.

That is true but returns a string. The procedure, however wants to make use
of the structure that is returned by as.character (or paste, through the former)
when applied to a formula: [1] is tilde [2] is response [3] is covariates. If
I use paste(deparse(...) ...) the structure is lost. I could probably get it
back (do not know, how), but that sounds like reinventing the wheel. I tried
to figure out, who does the magic: printing just the argument results a string,
but after using as.character, the structure appears. Looking at the C source,
I got lost, I must admit.

> The cutoff limit is 500, and a trivial change to the internals of
> as.character (which I have just made for 1.3.1) increases the cutoff from
> 60 to 500. Nevertheless. paste(deparse(mod, 500), collapse="") remains
> better.

Is in necessary to have an arbitrary limit? I do not know anything about C
(or any) programming, but the Hurd (for example) runs without a maximal path-
name length defined and R conformes to this.

Thank you,
Zsombor


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list