From p.dalgaard at biostat.ku.dk  Sun Nov 28 12:13:15 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Sun Nov 28 12:15:37 2004
Subject: [Rd] Is this a bug in the parser? (PR#7395)
In-Reply-To: <20041128043608.5CB7CEAC3@slim.kubism.ku.dk>
References: <20041128043608.5CB7CEAC3@slim.kubism.ku.dk>
Message-ID: <x2u0raw7jo.fsf@biostat.ku.dk>

rmh@temple.edu writes:

> # Your mailer is set to "none" (default on Windows),
> # hence we cannot send the bug report directly from R.
> # Please copy the bug report (after finishing it) to
> # your favorite email program and send it to
> #
> #       r-bugs@r-project.org
> #
> ######################################################
> 
> 
> 
> <<insert bug report here>>
> Is this a bug in the parser?

No (how could it be? If anything, this has to do with _de_parsing).
It's a bug (two, actually) in lattice, which has a maintainer....

Inside  latticeParseFormula

    parseCond <- function(model) {
        model <- eval(parse(text = paste("~", deparse(model))))[[2]]
        model.vars <- list()
        ....

and later on in the same function

    names(ans$condition) <- sapply(modelRHS.vars, deparse)

both of which whill get you in trouble if deparse needs multiple
lines. Notice that paste("~", deparse(model)) will prepend a "~" to
_every_ line, where only the first was intended, so you could have
gotten a parse error there and then.

The first bug is the sort of construct that I have been warning
people about repeatedly; computing on the language by going through
the textual representation as in parse(...deparse(...)) is almost
always wrong. In this particular case, I think the code is equivalent
to

  model <- substitute(~ m, list(m = model))

(minus the bug, of course). Bug #2 is probably just that you need to
take only the first line of deparse(), since you wouldn't want or need
the fully deparsed object for a name.
-- 
   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] Is this a bug in the parser? (PR#7395)
Peter Dalgaard