需要更新的软件包列表

时间:2014-02-18 15:30:47

标签: r updates r-package

如何生成需要更新的软件包列表,即包含软件包名称,当前安装的版本以及软件库中可用版本的表?

我尝试过hack packageStatus()installed.packages()update.packages(),但我无法强制这些功能产生所需的输出。

请注意,我想要实际更新这些包;我只是想看看提到的清单。

2 个答案:

答案 0 :(得分:6)

您是否了解函数old.packages()

来自help(update.packages)

 ‘old.packages’ indicates packages which have a (suitable) later 
 version on the repositories whereas ‘update.packages’ offers to
 download and install such packages.

答案 1 :(得分:6)

看看old.packages()。在我的系统上我有:

R> old.packages()
              Package         LibPath                                   Installed   Built   ReposVer    Repository                           
bnlearn       "bnlearn"       "/home/gavin/R/build/3.0-patched/library" "3.4"       "3.0.2" "3.5"       "http://cran.rstudio.com/src/contrib"
deldir        "deldir"        "/home/gavin/R/build/3.0-patched/library" "0.1-4"     "3.0.2" "0.1-5"     "http://cran.rstudio.com/src/contrib"
devtools      "devtools"      "/home/gavin/R/build/3.0-patched/library" "1.3"       "3.0.2" "1.4.1"     "http://cran.rstudio.com/src/contrib"
digest        "digest"        "/home/gavin/R/build/3.0-patched/library" "0.6.3"     "3.0.2" "0.6.4"     "http://cran.rstudio.com/src/contrib"
extrafont     "extrafont"     "/home/gavin/R/build/3.0-patched/library" "0.15"      "3.0.2" "0.16"      "http://cran.rstudio.com/src/contrib"
forecast      "forecast"      "/home/gavin/R/build/3.0-patched/library" "4.8"       "3.0.2" "5.1"       "http://cran.rstudio.com/src/contrib"
foreign       "foreign"       "/home/gavin/R/build/3.0-patched/library" "0.8-57"    "3.0.2" "0.8-59"    "http://cran.rstudio.com/src/contrib"
Matrix        "Matrix"        "/home/gavin/R/build/3.0-patched/library" "1.1-0"     "3.0.2" "1.1-2"     "http://cran.rstudio.com/src/contrib"
matrixStats   "matrixStats"   "/home/gavin/R/build/3.0-patched/library" "0.8.12"    "3.0.2" "0.8.14"    "http://cran.rstudio.com/src/contrib"
mgcv          "mgcv"          "/home/gavin/R/build/3.0-patched/library" "1.7-27"    "3.0.2" "1.7-28"    "http://cran.rstudio.com/src/contrib"
mvtnorm       "mvtnorm"       "/home/gavin/R/build/3.0-patched/library" "0.9-9996"  "3.0.2" "0.9-9997"  "http://cran.rstudio.com/src/contrib"
party         "party"         "/home/gavin/R/build/3.0-patched/library" "1.0-11"    "3.0.2" "1.0-13"    "http://cran.rstudio.com/src/contrib"
R.methodsS3   "R.methodsS3"   "/home/gavin/R/build/3.0-patched/library" "1.5.2"     "3.0.2" "1.6.1"     "http://cran.rstudio.com/src/contrib"
raster        "raster"        "/home/gavin/R/build/3.0-patched/library" "2.2-5"     "3.0.2" "2.2-12"    "http://cran.rstudio.com/src/contrib"
Rcpp          "Rcpp"          "/home/gavin/R/build/3.0-patched/library" "0.10.6"    "3.0.2" "0.11.0"    "http://cran.rstudio.com/src/contrib"
RcppArmadillo "RcppArmadillo" "/home/gavin/R/build/3.0-patched/library" "0.3.920.1" "3.0.2" "0.4.000.2" "http://cran.rstudio.com/src/contrib"
rgl           "rgl"           "/home/gavin/R/build/3.0-patched/library" "0.93.991"  "3.0.2" "0.93.996"  "http://cran.rstudio.com/src/contrib"
rpart         "rpart"         "/home/gavin/R/build/3.0-patched/library" "4.1-3"     "3.0.2" "4.1-5"     "http://cran.rstudio.com/src/contrib"
scatterplot3d "scatterplot3d" "/home/gavin/R/build/3.0-patched/library" "0.3-34"    "3.0.2" "0.3-35"    "http://cran.rstudio.com/src/contrib"
survival      "survival"      "/home/gavin/R/build/3.0-patched/library" "2.37-4"    "3.0.2" "2.37-7"    "http://cran.rstudio.com/src/contrib"

根据您的具体要求:

R> old.packages()[, c("Package","Installed","ReposVer")]
              Package         Installed   ReposVer   
bnlearn       "bnlearn"       "3.4"       "3.5"      
deldir        "deldir"        "0.1-4"     "0.1-5"    
devtools      "devtools"      "1.3"       "1.4.1"    
digest        "digest"        "0.6.3"     "0.6.4"    
extrafont     "extrafont"     "0.15"      "0.16"     
forecast      "forecast"      "4.8"       "5.1"      
foreign       "foreign"       "0.8-57"    "0.8-59"   
Matrix        "Matrix"        "1.1-0"     "1.1-2"    
matrixStats   "matrixStats"   "0.8.12"    "0.8.14"   
mgcv          "mgcv"          "1.7-27"    "1.7-28"   
mvtnorm       "mvtnorm"       "0.9-9996"  "0.9-9997" 
party         "party"         "1.0-11"    "1.0-13"   
R.methodsS3   "R.methodsS3"   "1.5.2"     "1.6.1"    
raster        "raster"        "2.2-5"     "2.2-12"   
Rcpp          "Rcpp"          "0.10.6"    "0.11.0"   
RcppArmadillo "RcppArmadillo" "0.3.920.1" "0.4.000.2"
rgl           "rgl"           "0.93.991"  "0.93.996" 
rpart         "rpart"         "4.1-3"     "4.1-5"    
scatterplot3d "scatterplot3d" "0.3-34"    "0.3-35"   
survival      "survival"      "2.37-4"    "2.37-7"