Displaying 1 result from an estimated 1 matches for "resf2".
Did you mean:
res2
2007 Aug 15
3
Formula in lm inside lapply
...)
res1
res2 <- lapply(levels(df$group),function(x) lm(y~x1+x2,df, subset =
group ==x))
res2
#try to pass formula into lm()--does not work
formula1 <- as.formula(y~x1)
formula2 <- as.formula(y~x1+x2)
resf1 <- lapply(levels(df$group),function(x) lm(formula1,df, subset =
group ==x))
resf1
resf2 <- lapply(levels(df$group),function(x) lm(formula2,df, subset =
group ==x))
Resf2
The error message is
'Error in eval(expr, envir, enclos): object "x" not found'
Any help is greatly appreciated!
Yan
--------------------------------------------------------
This is not an of...