Windows 7: installing multiple R packages through a script

I am trying to execute a script installation of R 2.15.1 on Windows 7. R installs just fine, but I cannot figure out how to install several packages from the same script series (or any script package, for that matter). Below is the part of the script where I name 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 the "R packages for GME.R", which contains packages for installation.

 install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE) 

Given documented ownership and ACL issues with writing to the default library folder in Windows , I tried the following:

  • Obtaining ownership of "C: \ Program Files \ R \ R-2.15.1 \ library", then starting R CMD BATCH <file> (no change);
  • Granting Full Control permissions for my user account in the same folder, and then running R CMD BATCH <file> (no change);
  • Changing the library folder to another location via Rprofile.site, then starting the R CMD BATCH <file> (no change);
  • Running the command through Rgui install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE) (works).

So far, I have not been able to use CMD or batch scripts to install packages. Is there something I'm missing? Any alternative ways to install the script package would be greatly appreciated.

In addition, the machines that I will install are designed for multiple users, so systems and system 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) after that, it gives Error in library(coda) : there is no package called 'coda' .

+4
source share
1 answer

The odesolve package is depreciated and replaced with deSolve. R 2.15.1 throws an error when meeting with this package. This may cause problems for you. Here I use the script to install packages for new R-installations.

 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) 
+8
source

Source: https://habr.com/ru/post/1444229/


All Articles