0

I am using the train function of caret package with r. If I specify a package that I have not installed, method displays the following.

1 package is needed for this model and is not installed. (***). Would you like to try to install it now?
1: yes
2: no

I would like to answer all "1: yes" without entering this question by hand every time, but how can it be done?

1 Answers1

1

This is an x-y problem

You should not look into installing inside caret train function but before it.

For example using:

list.of.packages <- c("your_package1", "your_package2")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)

Source: Elegant way to check for missing packages and install them?

Emmanuel-Lin
  • 1,848
  • 1
  • 16
  • 31