First post here. I am trying to create a linear regression with R by regressing each variable in the dataset with INFLATION.
for(i in 1:4) {
predictors_i <- colnames(data.all.inflation)[i+1]
summary(lm(predictors_i ~ data.all.inflation$INFLATION))
}
After running the code, the following error message appears:
Error in model.frame.default(formula = predictors_i ~ data.all.inflation$INFLATION, : variable lengths differ (found for 'data.all.inflation$INFLATION')
Please let me know if there are any more details that you want/need.Thanks!