[R] model.frame.default problem in function definition
Darryl Greig
darryl at hpli.hpl.hp.com
Sun Mar 2 16:20:04 CET 2003
Could someone point me in the right direction for the following issue:
A function is defined as follows:
tfun <- function(dat)
{
fmla <- as.formula("y~x+z")
dat2 <- dat
mdl <- lm(fmla,dat2)
mdl <- step(mdl)
}
Then the following code
dat <- data.frame(x=1:10,z=1:10,y=(1:10)^2+10*(1:10))
tfun(dat)
generates the output
Start: AIC= 43.67
y ~ x + z
Error in model.frame.default(formula = y ~ z, data = dat2,
drop.unused.levels = TRUE) :
Object "dat2" not found
Any help or pointers gratefully accepted.
Thanks,
Darryl Greig (darryl at hpli.hpl.hp.com)
More information about the R-help
mailing list