我试图脚本[R 2.15.1在Windows 7中的次安装R安装就好了,但我无法弄清楚如何从同一个批处理脚本安装多个软件包(或任何批处理脚本,对于这个问题)。下面是我称之为简单R文件的脚本部分。
"%ProgramFiles%\R\R-2.15.1\bin\R.exe" CMD BATCH "%~dp0R packages for GME.R"
以下是“RME for GME.R”的内容,其中包含要安装的软件包。
install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
鉴于documented ownership and ACLs issues with writing to the default library folder in Windows,我尝试了以下内容:
R CMD BATCH <file>
(无变更); R CMD BATCH <file>
(无更改); R CMD BATCH <file>
(无更改); install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
(工作)运行命令。到目前为止,我没有运气使用CMD或批处理脚本来安装软件包。有什么我想念的吗?任何替代脚本包安装的方法都将非常感激。
此外,我将安装的机器适用于多个用户,因此首选系统安装和配置。
//
编辑2012-11-06: 以下是.Rout文件中的错误消息:
install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
Warning in install.packages("CircStats", "coda", "deldir", "gplots", "igraph", :
'lib = "coda"' is not writable
Error in install.packages("CircStats", "coda", "deldir", "gplots", "igraph", :
unable to install packages
Execution halted
如果我之后执行library(coda)
,则会提供Error in library(coda) : there is no package called ‘coda’
。
答案 0 :(得分:8)
odesolve软件包已弃用,已被deSolve取代。 R 2.15.1遇到此程序包时抛出错误。它可能会给你带来麻烦。这是我用于安装新R安装包的脚本。
libs=c("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields")
type=getOption("pkgType")
CheckInstallPackage <- function(packages, repos="http://cran.r-project.org",
depend=c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances"), ...) {
installed=as.data.frame(installed.packages())
for(p in packages) {
if(is.na(charmatch(p, installed[,1]))) {
install.packages(p, repos=repos, dependencies=depend, ...)
}
}
}
CheckInstallPackage(packages=libs)