How to update R from 3.x to 4.x and should I?

2020-08-05 09:49发布

问题:

With R 4.0.0 and recently R 4.0.1 being released recently, I would like to know how to upgrade?

Previously I used UpdateR from the installR package.

Will it work just as well upgrading to 4.x?

The documentation for 4.0.0 states that:

Packages need to be (re-)installed under this version (4.0.0) of R

Will updateR re-install everything and if not, how can I get list of packages to install in a reasonable amount of time.

I cannot believe I can't find any 4.x install or update details elsewhere, most importantly are there any specific issues or limitation or code changes required in 4.x from 3.x.

Also I use Rbuild Tools for Rcpp. Do I need to update those tools to 4.0 as well and is there a special way to do so?

回答1:

I did this a few weeks ago.
UpdateR didn't migrate the packages as expected, so that I had to do it manually :

  • Install R 4.0.x
  • Install RTools 4.0, take care to set $Path correctly as instructed. This new version is necessary for R 4.0 to compile from source some packages still in 3.x
  • Migrate the packages from R 3.x to R 4.x :
# locate packages
.libPaths()
[1] "/Documents/R/win-library/4.0" 
# Migration list : replace previous 4.0 by 3.x in old_lib_loc
old_lib_loc <- "/Documents/R/win-library/3.x"
to_install <- unname(installed.packages(lib.loc = old_lib_loc)[, "Package"])
# Check if list is OK or if you want to clean up
to_install
[1] "abind"                "acepack"              "ada"                  "alphavantager"                   
[6] "ash"                  "askpass"              "assertive"            "assertive.base"       "assertive.code"  
# Migrate
install.packages(pkgs = to_install,Ncpus = 4) 

Packages still in 3.x are automatically recompiled from source.
That's it, no problems encountered since then.



标签: r