Re: [Rd] model.matrix.default chokes on backquote (PR#7202)

From: Gabor Grothendieck <ggrothendieck_at_myway.com>
Date: Tue 31 Aug 2004 - 00:21:03 EST

Peter Dalgaard <p.dalgaard@biostat.ku.dk> writes:
>
> "Gabor Grothendieck" <ggrothendieck@myway.com> writes:
>
> > > y ~ `offset(foo)` + offset(foo)
> > >
> > > I.e. perhaps the real issue is that names(data) gets generated without
> > > backquotes.
> > >
> > > Anyways, this is a real can of worms and I'm not sure we're not too
> > > close to 2.0.0 to start tampering with it...
> >
> > How about a partial fix that does not address pathological
> > cases where the variable names themselves have embedded
> > backquotes but does address the common cases such as:
> >
> > y <- ts(1:10); x1 <- y^2; x2 <- y^4
> > lm(`lag(y)` ~ ., cbind(lag(y), x1, diff(x2)) )
> >
> > without having to resort to:
> >
> > lm(lag.y ~ ., cbind(lag.y = lag(y), x1, diff(x2)) )
>
> Hmmm... Point taken, but I'm not happy about the fact that the
> internals seem unable to discern `lag(y)` (the name) and lag(y) (the
> call). One might consider "backtickifying" the names of the data
> matrix instead:
>
> > bq <- function(x)sapply(x,
> function(nm)deparse(as.name(nm),backtick=TRUE))
> > bq(c("a","a(b)"))
> a a(b)
> "a" "`a(b)`"

Just one other comment. The reason that the example I provided arises is that one cannot write:

      lm(lag(y) ~ x1 + diff(x2))
or

      lm(lag(y) ~ x1 + diff(x2), cbind(y, x1, x2))

For these to work it would have to align the time scales of ts objects passed to it.



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Aug 31 00:25:01 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:11 EST