I wrote some code to automate printing out a list of ANOVA models that all use the same independent variable. I created a vector of all the numeric variables in a data frame. Then I used a for loop to create the necessary ANOVA models, the name of the dependent variable in each model, & the summary of the model.
I have used this block of code before with no problems, but when I tried running it today, I got the error message "Error: object 'anova_models' not found." Is there an issue with some command being deprecated? Or is R trying to discourage creating list objects out of ANOVA models? Am I following an incorrect naming convention?
numeric_columns <- which(sapply(iris, is.numeric)) ## Creates a named integer vector of column number for numeric variables in the data frame.
for (i in 1:length(numeric_columns)) {
anova_models[[i]] <- aov(unlist(iris[,numeric_columns[[i]])~Species, data = iris)
print(names(numeric_columns[[i]])
print(summary(anova_models[[i]])
}
Does anybody have an idea what might be keep this block of code from running?