How to create a loop that will make regression models in R? [closed]
Assuming you’re just using lm the trick is to change the data argument to subset to something different. speciesList <- unique(df$Species) for(i in 1:length(speciesList){ lmmodel <- lm(x ~ year, data = subset(df, Species == speciesList[i])) #Now do all the stuff you want with lmmodel, e.g. plot, find slope, etc } I’m not going to write … Read more