[Rd] terms.formula(y ~ (x + fn(z = NA)) - fn(z = NA), simplify=TRUE) does not simplify
Helske Jouni
jouni.helske at jyu.fi
Sun Mar 31 22:56:03 CEST 2013
Dear all,
I'm trying to use update.formula for removing a function in formula, but when the function has argument set as NA, this doesn't seem to work. I was able to track the issue to terms.formula function (.Internal(terms.formula(..))), but couldn't figure out anything useful from corresponding C code in src/main/model.c. Here's an example of the issue:
> rm(list=ls())
> tmp<-terms.formula(y ~ (x + fn(z = NA)) - fn(z = NA),simplify=TRUE)
> tmp
y ~ x + fn(z = NA)
attr(,"variables")
list(y, x, fn(z = NA), fn(z = NA))
attr(,"factors")
x fn(z = NA)
y 0 0
x 1 0
fn(z = NA) 0 1
fn(z = NA) 0 0
attr(,"term.labels")
[1] "x" "fn(z = NA)"
attr(,"order")
[1] 1 1
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
> formula(tmp)
y ~ x + fn(z = NA)
with fn(z=a) it works fine, and also with NA_character_ (but not with NA_real_):
> rm(list=ls())
> tmp<-terms.formula(y ~ (x + fn(z = NA_character_)) - fn(z = NA_character_),simplify=TRUE)
> tmp
y ~ x
attr(,"variables")
list(y, x, fn(z = NA_character_))
attr(,"factors")
x
y 0
x 1
fn(z = NA) 0
attr(,"term.labels")
[1] "x"
attr(,"order")
[1] 1
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
> formula(tmp)
y ~ x
Is this what is supposed to happen?
Best regards,
Jouni Helske
More information about the R-devel
mailing list