From p.dalgaard at biostat.ku.dk  Mon Aug 30 08:34:35 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Mon Aug 30 08:39:55 2004
Subject: [Rd] model.matrix.default chokes on backquote (PR#7202)
In-Reply-To: <20040830013521.DDAEC39AA@mprdmxin.myway.com>
References: <20040830013521.DDAEC39AA@mprdmxin.myway.com>
Message-ID: <x2r7ppp210.fsf@biostat.ku.dk>

"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)`"


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] model.matrix.default chokes on backquote (PR#7202)
Peter Dalgaard