Automatically update packages installed from R-forge

夙愿已清 提交于 2019-11-29 18:57:13
Sharpie

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?
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!