我正在用r插入符号的训练功能。 如果我指定了尚未安装的软件包,则method将显示以下内容。
1 package is needed for this model and is not installed. (***). Would you like to try to install it now?
1: yes
2: no
我想回答所有“ 1:是”,而不必每次都手动输入此问题,但是该怎么做?
答案 0 :(得分:1)
您不应该考虑在caret
train
函数内部进行安装,而是先于它进行安装。
例如使用:
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)
来源:Elegant way to check for missing packages and install them?