Question

How can I produce a list of packages that need an update, i.e. a table with package name, version currently installed and version available at the repository?

I have tried to hack packageStatus(), installed.packages(), update.packages() but I am not able to force these functions to produce the desired output.

Note that I don't want to actually update these packages; I just want to see the mentioned list.

Was it helpful?

Solution

Take a look at old.packages(). on my system I have:

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"

For your specific requirements:

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" 

OTHER TIPS

Are you aware of the function old.packages() ?

From 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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top