Monday, November 14, 2016

R - upgrade all packages

  • How to upgrade R?

There is this package, which you can use .... but you must have it installed before new version of R come ;-) - otherwise it is typical "catch 22":
Upgrade from 3.3.1  to 3.3.2 :
install.packages('installr', repos = 'http://cran.us.r-project.org') 
Warning message: 
package ‘installr’ is not available (for R version 3.3.1)


So basically - instead this go to https://cran.r-project.org/ and update using new R.


  • How to upgrade all your existing R packages (libraries)?

Use this command to upgrade all existing packages:

install.packages(
  .libPaths()[1],
  pkgs = as.data.frame(installed.packages(.libPaths()[1]), stringsAsFactors=FALSE)$Package,
  type = 'source'
)
And quick update - to the article ;-) - use this instead:

update.packages()
update.packages(ask = FALSE, dependencies = c('Suggests'))

Have a fun! 

1 comment:

  1. Hi, I did this but it did not work. My R version is 3.4.1, I just actualized it. I keep getting package 'installr' is not available (for R version 3.4.1)

    ReplyDelete