Automatically update packages installed from R-forge

前端 未结 1 1025
小鲜肉
小鲜肉 2020-12-22 18:42

I recently installed R-2.12.0 from R-2.11.1 and I\'ve updated all CRAN packages via:

update.packages(checkBuilt=TRUE, ask=FALSE)

Now I want

相关标签:
1条回答
  • 2020-12-22 19:22

    How about this:

    # 1. Get the list of packages you have installed, 
    #    use priority to exclude base and recommended packages.
    #    that may have been distributed with R.
    pkgList <- installed.packages(priority='NA')[,'Package']
    
    # 2. Find out which packages are on CRAN and R-Forge.  Because
    #    of R-Forge build capacity is currently limiting the number of
    #    binaries available, it is queried for source packages only.
    CRANpkgs <- available.packages(
      contriburl=contrib.url('http://cran.r-project.org'))[,'Package']
    forgePkgs <- available.packages(
      contriburl=contrib.url('http://r-forge.r-project.org', type='source')
    )[,'Package']
    
    # 3. Calculate the set of packages which are installed on your machine,
    #    not on CRAN but also present on R-Force.
    pkgsToUp <- intersect(setdiff(pkgList, CRANpkgs), forgePkgs)
    
    # 4. Update the packages, using oldPkgs to restrict the list considered.
    update.packages(checkBuilt=TRUE, ask=FALSE,
      repos="http://r-forge.r-project.org",
      oldPkgs=pkgsToUp)
    
    # 5. Profit?
    
    0 讨论(0)
提交回复
热议问题