I'd like to achieve something to the effect of

libs = c("AER", "gbm", "caret", "MASS", "nnet", "randomForest")
for (i in libs) {
  if(!is.element(i, .packages()) {
    install.packages(i)
  }
  library(i)
}

The call to library(i) does not replace i with the value being stored in the variable i. Instead, it tries to load the library called "i"

Is there a way to force i to be treated as a variable and resolved before the call to the library?

r
Edit
Report