如何不需要用户输入 install.packages(type = "both")

How to not need user input for install.packages(type = "both")

通常,如果有需要从源构建的包,install.packages(..., type = "both") 需要用户输入。

例如(目前,使用 R 3.5.1),install.packages(c("feather", "tidyr"), type = "both")) 将从二进制文件安装 tidyr,从源代码安装 feather,只要有用户在到达时单击 "yes"羽毛安装。

有没有办法自动点击是,或者不需要用户通过某些选项输入install.packages()

注意: install.packages(..., type = "source") 不需要用户输入,但它会构建所有包,这在这种情况下不是理想的行为。

install.packages.compile.from.source 选项可以设置为 "always" 以从源安装包而不提示 UI。默认为"interactive",使用type="both"时会提示用户确认。

解决方案:

options(install.packages.compile.from.source = "always")
install.packages(c("feather","tidyr"), type = "both")