I am trying to script the installation of R 2.15.1 on Windows 7. R installs just fine, but I cannot figure out how to install multiple packages from the same batch script (or any batch script, for that matter). Below is the part of the script where I call a simple R file.
"%ProgramFiles%\R\R-2.15.1\bin\R.exe" CMD BATCH "%~dp0R packages for GME.R"
Here is the contents of "R packages for GME.R" that has the packages to install.
install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
Given documented ownership and ACLs issues with writing to the default library folder in Windows, I've tried the following:
R CMD BATCH <file>
(no change);R CMD BATCH <file>
(no change);R CMD BATCH <file>
(no change);install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
(works).So far, I have had no luck using CMD or batch scripts to install packages. Is there something I'm missing? Any alternative ways of scripting package installation would be greatly appreciated.
Also, the machines I will be installing on are for multiple users, so system-wide installations and configurations are preferred.
//
Edit 2012-11-06: Here is the error message from the .Rout file:
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
If I execute library(coda)
afterwards, it gives Error in library(coda) : there is no package called ‘coda’
.
The odesolve package is depreciated and has been replaced by deSolve. R 2.15.1 is throwing an error when encountering this package. It could be causing problems for you. Here's a script I use for installing packages for new R installs.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With