Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade R in linux?

I am new to Linux. I am using Linux mint 18.1. I have installed R using system software manager. My current R version is 3.2. But I want to upgrade it to version 3.4.

How can I do it?

like image 315
Ayubur Rahaman Avatar asked Sep 14 '17 08:09

Ayubur Rahaman


People also ask

How do I update R in RStudio Linux?

If you want to update to the latest version of RStudio, hover over “Help” on the top menu bar of your Mac, and click “Check for Updates”. Then, quit the RStudio program, go to the RStudio website, and download and install the latest version. Now you should have the latest versions of R and RStudio on your computer.

How do I upgrade my R version?

Upgrading your version of R If you decide to upgrade your version of R, simply choose a CRAN mirror in the download page and follow the procedure you used to initially download and install R. The installation will automatically install the new version and make it available within RStudio.

How do I update R version from command line?

For command line use you can update R by running: require(installr) updateR() # this will open dialog boxes to take you through the steps. Or install a new software simply by running: require(installr) installr() # user can easily select (via a GUI interface) a software to install.

Can we install R in Linux?

Step 1: Open terminal (Ctrl+Alt+T) in Ubuntu. Step 2: Update the package's cache. Step 3: Install R environment. Step 4: Check R installation by using the following command.


1 Answers


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.


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:

Step 1

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/

Step 2

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 

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.

Step 3

Start a new R session and run the following:

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

Then you should be good to go.

Update: Linux Mint 19 and 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 

you need to use

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

(replacing http://cran.wustl.edu/ with whichever CRAN mirror URL you chose in step 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).

like image 146
duckmayr Avatar answered Sep 29 '22 13:09

duckmayr