Dear All,

I have data which contains 14 variables. And I have to regress one of
variables on each variable (simple 13 linear regressions)

I try to make a loop and store only R-squared

 colnames(boston)
 [1] "CRIM"    "ZN"      "INDUS"   "CHAS"    "NOX"     "RM"      "AGE"
 [8] "DIS"     "RAD"     "TAX"     "PTRATIO" "B"       "LSTAT"   "MEDV"

name <-  colnames(boston)

r <- rep(0, 13)
for(i in 1: 13) {
  r[i] <- summary(lm(MEDV ~ name[i], data = boston))$r.squared
}

but this doesn't work because name have " " for each variable. How to
remove " " for name of each variable?
Or do you know the way I can do regression MEDV on each variable?

Thank you ahead,
Soyeon

______________________________________________
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.

Reply via email to