R语言现在的版本是R4.0,R的包一般是3.5一个目录,3.6一个目录,4.0一个目录。小版本的更新,会公用一个目录,比如4.0.5和4.0.6是不需要变化目录的,library中的包应该是兼容的。

看我的R包的目录:里面有3.6和4.0两个文件夹,里面是R包。

C:\Users\dave\Documents\R\win-library

更新R语言版本后,什么是最好的方法更新R包?_重新安装

每次更新,都要重新安装R包,是一个漫长的过程。有没有快一点的方法呢?

有,看官网怎么说:

更新R语言版本后,什么是最好的方法更新R包?_重新安装_02

英文:


2.8 What’s the best way to upgrade?
That’s a matter of taste. For most people the best thing to do is to uninstall R (see the previous Q), install the new version, copy any installed packages to the library folder in the new installation, run update.packages(checkBuilt=TRUE, ask=FALSE) in the new R and then delete anything left of the old installation. Different versions of R are quite deliberately installed in parallel folders so you can keep old versions around if you wish.



For those with a personal library (folder R\win-library\x.y of your home directory, R\win64-library\x.y on 64-bit builds), you will need to update that too when the minor version of R changes (e.g. from 4.0.2 to 4.1.0). A simple way to do so is to copy (say) R\win-library\4.0 to R\win-library\4.1 before running update.packages(checkBuilt=TRUE, ask=FALSE).


所以,不同的人,采用不同的方法,是属于个人品味的问题。

比如处女座:

我要把旧版本的R全部卸载,手动安装就行,用什么再安装。

比如不是处女座的我,使用官方推荐的方法:

我要R3.6,也要R4.0,我全部都要,所以呢,我的R3.6升级到R4.0后,

1, 下载安装R4.0

就是下载安装就行了

2,将3.6的文件夹内容复制到4.0里面

更新R语言版本后,什么是最好的方法更新R包?_r语言_03

3. 然后打开R4.0,运行下面命令

update.packages(checkBuilt=TRUE, ask=FALSE)

然后就是各种更新了。因为已经copy过了,所以3.6的包能在4.0上的,就不会重新安装,不能用的,就会自动安装。

注意:

为了一切顺利,windows系统,建议安装Rtools。

网址:https://cran.r-project.org/bin/windows/Rtools/

更新R语言版本后,什么是最好的方法更新R包?_下载安装_04

4. 双击666吧