如何在 linux 中升级 R?

How to upgrade R in linux?

我是 Linux 的新手。我正在使用 Linux mint 18.1。我已经使用系统软件管理器安装了 R。我当前的 R 版本是 3.2。但是我想升级到3.4版本。

我该怎么做?


注意:我现在继续 GitHub (here) 在 Linux Mint 上升级 R 的最新指南或 Ubuntu Linux,其中还包括一些关于 tidyverse、流行的数据整理包集以及 devtools、流行的系统依赖项的一些额外信息R包开发...包。


FedRo is a good resource, however a slight change would need to be made since you're using Linux Mint 18.1 which uses Xenial repositories rather than Trusty repositories (see here). I also typically use the approach here 提供的 link 用于处理我在升级 R 时已经安装的包,而不是 FedRo 提供的方法。因此,为了完整起见,这些是您需要执行的所有步骤:

第 1 步

转到CRAN's list of mirrors and find the URL of the mirror that is closest to you. The terminal commands below assume you choose http://cran.wustl.edu/

第 2 步

打开终端并输入以下命令1(将 http://cran.wustl.edu/ 替换为您在步骤 1 中选择的任何 CRAN 镜像 URL):

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo echo "deb http://cran.wustl.edu/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt upgrade r-base r-base-dev
sudo apt update
sudo apt upgrade

另请注意,我已将 r-baser-base-dev 升级,但我不知道您是否安装了 r-base-dev。如果没有,我强烈建议您通过 sudo apt install r-base-dev.

安装它

第 3 步

开始新的 R 会话并运行以下内容:

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

那你就可以开始了。

更新:LinuxMint 19 和 R 3。6.x

自从我回答这个问题后 Linux Mint 和 R 都看到了升级,我正在为那些需要 Linux Mint 19 和 R 3 信息的人更新。 6.x.

唯一的区别是,而不是命令

sudo echo "deb http://cran.wustl.edu/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list

你需要使用

sudo echo "deb http://cran.wustl.edu/bin/linux/ubuntu bionic-cran35/" | sudo tee -a /etc/apt/sources.list

(将 http://cran.wustl.edu/ 替换为您在步骤 1 中选择的任何 CRAN 镜像 URL)


1 我把完整的密钥放在这里,尽管你可能看到的许多其他指南只使用 "short key." 出于安全考虑,我更新了本指南以使用完整密钥(例如,参见 here)。

现在很简单了。只需:

install.packages("ropenblas")
ropenblas::rcompiler()