Chris Friedl <cfriedalek <at> gmail.com> writes: > I have two questions about the built-in function step. Ultimately I want to > apply a lm fitting and subsequent step procedure to thousands of data sets > groups by a factor defined as a unique ID. > > Q1. The code below creates a data.frame comprising three marginally noisy > surfaces. The code below fails when I use step in a function but summary > seems to show the model fits are legitimate. Any ideas on what I'm doing > wrong?
... Well designed example code omitted > function(x){lm(model, data = x)}) > lapply(fits, function(x){summary(x)}) > > # FAIL > lapply(fits, function(x){step(x)}) .... > Error in as.data.frame.default(data) : > cannot coerce class "lm" into a data.frame Looks like an environment problem. I could not find a workaround quickly, but you might have a look at http://finzi.psych.upenn.edu/R/Rhelp02a/archive/16599.html We call it "Ripley's Game" here, because variants of it can help you quite often. Dieter ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.