且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Linux中升级R?

更新时间:2023-02-22 20:15:26


注意:我现在继续使用GitHub(此处)有关在Linux Mint或Ubuntu Linux上升级R的最新指南,其中还包括有关tidyverse,流行的数据处理软件包以及devtools,流行的R包开发...包.


Note: I now keep on GitHub (here) an up-to-date guide to upgrading R on Linux Mint or Ubuntu Linux, which also includes a bit of extra information about system dependencies for tidyverse, the popular set of data-wrangling packages, as well as devtools, the popular R package development... package.

FedRo 提供的链接是很好的资源,但是由于您是使用Linux Mint 18.1,它使用Xenial仓库而不是Trusty仓库(请参见此处).我通常还会使用此处的方法来处理我在安装时已经安装的软件包升级R,而不是FedRo提供的方法.因此,为了完整起见,这些都是您需要采取的所有步骤:

The link provided by 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 to deal with packages I've already installed when I upgrade R rather than the approach offered by FedRo. So, for completeness, these are all the steps you'd need to take:

转到 CRAN的镜像列表,然后找到最接近的镜像的URL.给你.下面的终端命令假定您选择 http://cran.wustl.edu/

Go to 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/

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

Open a terminal and enter the following commands1 (replacing http://cran.wustl.edu/ with whichever CRAN mirror URL you chose in step 1):

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安装它.

Note also that I have put to upgrade r-base and r-base-dev, but I don't know if you have r-base-dev installed. If not, I highly recommend you install it via sudo apt install r-base-dev.

开始一个新的R会话并运行以下命令:

Start a new R session and run the following:

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

那你应该很好.

由于自从我回答了这个问题以来,Linux Mint和R都经历了升级,因此我正在为那些需要Linux Mint 19和R 3.6.x的信息的人进行更新.

Since both Linux Mint and R have seen upgrades since I answered this question, I'm updating for those who come to this answer needing the info for Linux Mint 19 and R 3.6.x.

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

The only difference is that instead of the command

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

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

(replacing http://cran.wustl.edu/ with whichever CRAN mirror URL you chose in step 1)

1 我将完整键放在这里,尽管您可能会看到的许多其他指南仅使用短键". 我已经更新了本指南,以出于安全考虑使用完整密钥(请参阅此处).

1 I put here the full key, though many other guides you may see will use only the "short key." I have updated this guide to use the full key out of security concerns (see here, for example).