How do I return an object from a function, rather than the output provided when you call the object?
best.mod <- function(d){
m1 <- lm(Sepal.Length~Sepal.Width, d)
m2 <- lm(Sepal.Length~Sepal.Width + I(Sepal.Width^2), d)
ifelse(AIC(m1) < AIC(m2), m1, m2)
}
mod <- best.mod(iris[iris$Species == "setosa",])
class(mod)