[R] changes to terms.formula in 2.3.x

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Tue Jun 20 19:26:36 CEST 2006


Thanks, Gabor. Works like a charm.

--sundar

Gabor Grothendieck wrote:
> Try this:
> 
>> fo <- ~ x | y
>> fo[[3]] <- fo[[2]]
>> fo[[2]] <- as.name("z")
>> fo
> 
> z ~ x | y
> 
> On 6/20/06, Sundar Dorai-Raj <sundar.dorai-raj at pdf.com> wrote:
> 
>> Hi, all,
>>
>> I just recently noticed a change in terms.formula from 2.2.1 to 2.3.1
>> (possibly 2.3.0, but I didn't check). Here's the problem:
>>
>> ## 2.2.1
>>  >  update(~ x | y, z ~ .)
>> z ~ x | y
>>
>> ## 2.3.1
>>  > update(~ x | y, z ~ .)
>> z ~ (x | y)
>>
>> and in the NEWS for 2.3.1
>>
>>     o  terms.formula needed to add parentheses to formulae with
>>        terms containing '|'.  (PR#8462)
>>
>> So, there must be a reason for this change. However, in the lattice
>> framework I have this causes many problems because now the `|' is
>> interpreted as a logical OR. Could someone suggest a workaround for me
>> so that I still get the 2.2.1 behavior my code relies on. Here's a very
>> simple test function (works in 2.2.1, fails in 2.3.1):
>>
>> library(lattice)
>> foo <- function(x, data) {
>>   x <- update(x, y ~ .)
>>   xyplot(x, data)
>> }
>> z <- expand.grid(x = 1:10, g = letters[1:3])
>> z$y <- rnorm(nrow(z))
>> foo(~ x | g, z)
>>
>> Thanks,
>>
>> --sundar
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! 
>> http://www.R-project.org/posting-guide.html
>>



More information about the R-help mailing list