Windows 7: Installing multiple R packages via script

后端 未结 1 1377
别那么骄傲
别那么骄傲 2021-01-19 10:43

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 (

相关标签:
1条回答
  • 2021-01-19 11:36

    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)
    
    0 讨论(0)
提交回复
热议问题