2014-02-18 111 views
6

如何生成需要更新的軟件包列表,即包含軟件包名稱,當前安裝的版本和版本庫中的可用版本?需要更新的軟件包列表

我試過hack packageStatus(),installed.packages(),update.packages()但我不能強制這些函數產生所需的輸出。

請注意,我不要想要實際更新這些包;我只想看看提到的列表。

回答

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" 
+1

擊敗你八秒;-) –

+1

@DirkEddelbuettel是的,但我的答案更大:P –

+1

但是,從一個顯然無效的系統,因爲你顯示過時的Rcpp在使用。 –

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. 
+0

德克,感謝您的回答。 OT:如果您有任何有關從R運行JAGS的經驗,我想請您擔任MCMC大師。我正在努力處理R2jags和runjags包中的錯誤。但是你可能使用了一些Rcpp魔法? :-) – TMS

+0

@Tomas我想你應該爲此提出一個新問題。 –

+0

Dirk,我很喜歡,但恐怕有一個像「運行JAGS的最佳方式是什麼」的問題會在不到5秒的時間內關閉:-)更不用說像「Dirk,真正的大師正在使用什麼」這樣的問題: - ) – TMS