问题描述
我有一个 R 脚本,它与不同计算机上的多个用户共享.其中一行包含 install.packages("xtable")
命令.
I have an R script that is shared with several users on different computers. One of its lines contains the install.packages("xtable")
command.
问题在于,每次有人运行脚本时,R 显然会花费大量时间重新安装包(实际上确实需要一些时间,因为真实案例有多个包的向量).
The problem is that every time someone runs the script, R spends a great deal of time apparently reinstalling the package (it actually does take some time, since the real case has vector of several packages).
我怎样才能先检查软件包是否已安装,然后只为未安装的软件包运行 install.packages()
?
How can I make first check if the packages are installed and then only run install.packages()
for the ones that are not?
推荐答案
try: require("xtable")
or "xtable" %in% rownames(installed.packages())
这篇关于在运行 install.packages() 之前检查已安装的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!