RICHARD M. HEIBERGER
2010-Nov-29 04:29 UTC
[R] formulas with non-syntactic names and an Error() term
## This is an example where ``-quoted non-syntactic names work in
## simple formulas, but not in formulas with an Error() term.
## Is this intentional or an oversight when ``-quoted names were added?
tmp <- data.frame(y=1:6,
`x^1`=factor(c(1,2,1,2,1,2)),
`x^2`=factor(c(1,1,2,2,3,3)),
check.names=FALSE)
tmp
aov(y ~ `x^1` + `x^2`, data=tmp) ## ok
aov(y ~ `x^1` + `x^2` + Error(1), data=tmp) ## error
## Error in `[.data.frame`(mf, xvars) : undefined columns selected
tmp2 <- data.frame(tmp)
tmp2
aov(y ~ x.1 + x.2 + Error(1), data=tmp2) ## this is ok
## this is Windows R-2.12.0
## Rich
[[alternative HTML version deleted]]
Apparently Analagous Threads
- [External] Creating model formulas programmatically
- [External] Creating model formulas programmatically
- [External] Creating model formulas programmatically
- [External] Creating model formulas programmatically
- [External] Creating model formulas programmatically
