旧版

可以直接在R studio 中下载新版本的R。

但是mac 不像windows,可以很方便的进行R 的版本控制。

因此使用installr 包中的updateR 函数,查了下教程:

  1. install.packages("installr")
  2. library(installr)
  3. updateR()

发现这个包不在,找了一下,发布在github 上:

  1. remotes::install_github("andreacirilloac/updateR")

发现还是下载的好慢啊,简直龟速!

那就尝试自行下载R 本地安装:https://www.yuque.com/mugpeng/rr/kkz6pg

把项目下载到R 环境中,直接安装:

  1. > install.packages("updateR-master", repos=NULL, type="source")

好的很:

  1. > library(updateR)
  2. A new version R of 4.0.3 is available for update!
  3. run updateR() to get the latest R on your macOS!
  4. > updateR()
  5. Enter password for appe:

孩子哭了:

  1. Updated ~/.Rprofile
  2. Password:错误: Latest R Version 4.0.3 requires macOS at least 10.13 or higher,
  3. but 10.12 is running. Consider upgrading macOS or install legacy R binaries from
  4. http://cran.rstudio.com/bin/macosx/

我sierra 永不为奴!!

07. mac 更新R 的方式 - 图1

新版

到头来还是真香了:

07. mac 更新R 的方式 - 图2

发现网上有人使用的是installr(我们下载的包也叫updateR) 中的函数:

  1. updateR(fast=TRUE,cran_mirror="https://mirrors.ustc.edu.cn/CRAN/")

但读了一下updateR 这个包,发现其并不能设置镜像,而且竟然还是只能在mac os 上使用。

查看了一下,发现updateR 和installr 这两个包分别对应了win os 与mac os 的两个系统。

在win os 中,installr 还提供了copy.packages.between.libraries 包实现迁移。

而且在我的电脑上,updateR 无关顺利完成更新,而且其也无法设置镜像,完成更新后只不过下载了一个新版本的R 罢了!

再试试看手动下载R 和手动迁移包吧。有个方法:https://stackoverflow.com/questions/13656699/update-r-using-rstudio

关于新旧迁移,直接参见:

18. mac os R包新旧版本的迁移问题