Displaying 1 result from an estimated 1 matches for "suffixx".
Did you mean:
suffix
2012 May 29
3
trouble automating formula edits when log or * are present; update trouble
...ate code I'm testing doesn't get right.
Here's the test code:
##PJ
## 2012-05-29
dat <- data.frame(x1=rnorm(100,m=50), x2=rnorm(100,m=50),
x3=rnorm(100,m=50), y=rnorm(100))
m1 <- lm(y ~ log(x1) + x1 + sin(x2) + x2 + exp(x3), data=dat)
m2 <- lm(y ~ log(x1) + x2*x3, data=dat)
suffixX <- function(fmla, x, s){
upform <- as.formula(paste0(". ~ .", "-", x, "+", paste0(x, s)))
update.formula(fmla, upform)
}
newFmla <- formula(m2)
newFmla
suffixX(newFmla, "x2", "c")
suffixX(newFmla, "x1", "c")
Th...