Updating a package in R: `update.packages` vs` install.packages`

I tried loading the library partyand received the following error:

 Loading required package: zoo
 Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
   namespace ‘lattice’ 0.20-24 is already loaded, but >= 0.20.27 is required
 Error: package ‘zoo’ could not be loaded

Therefore, I decided to update all the packages in one session ( disconnect all packages while working in R ), including lattice, hoping that zoo, and then it partywill load correctly after the update lattice:

 pkgs <- names( sessionInfo()$otherPkgs )
 pkgs <- paste('package:', pkgs, sep = "")
 lapply( pkgs , detach, character.only = TRUE, unload = TRUE)
 update.packages(checkBuilt=TRUE, ask=FALSE,
                 repos="http://r-forge.r-project.org",
                 oldPkgs=c("lattice","zoo","party")
 )

This did not work (during the same session and after restarting without preloading .RData):

 > library(party)
 Loading required package: zoo
  Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
   namespace ‘lattice’ 0.20-24 is already loaded, but >= 0.20.27 is required
   Error: package ‘zoo’ could not be loaded

According to How to update R2jags in R? , it’s better to just run install.packagesin the packages that I want to upgrade and then restart. And indeed, this did the trick.

, : update.packages, , , install.package ? R voodoo ? .

+4
2

, "" "" R.

, R , , , . update.r install.r littler ( examples/ ), , , Rscript.

+7

Dirk , . , , , , ( detach(.) -ing update.packages(.) -ing), unloadNamespace, . , , , . :

unloadNamespace("lattice")   # or lapply()-ing as you attempted with `detach`
update.packages("lattice")
require(lattice)  # or library()
+7

Source: https://habr.com/ru/post/1547324/


All Articles