R is a powerful open-source programming language used widely for data analysis and statistical computing. With its growing popularity, many users want to install R on their Ubuntu systems to start using it for their data analysis needs.
If you’re new to R or to installing software on Ubuntu, this step-by-step guide will help you install R on your Ubuntu systems.
Installing R on Ubuntu
You can install R programming language on Ubuntu with a few steps below:
- First update the indices on your system
sudo apt update
- Now install the following helper packagers
sudo apt install --no-install-recommends software-properties-common dirmngr
- Add the GPG key to your system
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
- Next configure the PPA on the ubuntu system.
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
Here we use
`lsb_release -cs`
to access which Ubuntu flavor you run: one of “jammy”, impish”, “focal”, “bionic”, … - Finally, install the R programming language with the following command.
Then runsudo apt install --no-install-recommends r-base
This installs the R packages and dependencies on your system.
- Once the installation is finished, check the R version:
R --version
This will display the version of R that you have installed. You should have R version 4.0.3 or higher.
Adding PPA for 5000+ CRAN Packages
The c2d4u contains 5000+ CRAN packages for the installation th Run this command (as root or by prefixing sudo) to add the current R 4.0 or later ‘c2d4u’ repository:
sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+
The ‘c2d4u’ repository is only available for LTS releases.
Installing R Studio
If you want to use R with a user-friendly interface, you can also install R Studio, which is an integrated development environment for R. To install R Studio, you can download the .deb file from the R Studio website and then use the dpkg command to install it.
Download the R-Studio Debian package with one of the following commands:
- On Ubuntu 22.04:
wget -nc https://download1.rstudio.org/electron/jammy/amd64/rstudio-2022.12.0-353-amd64.deb
- On Ubuntu 20.04 / 18.04:
wget -nc https://download1.rstudio.org/electron/bionic/amd64/rstudio-2022.12.0-353-amd64.deb
Now, we can install it using the `dpkg`
command line tool. But I suggest using the `apt`
package manager to install the locally downloaded files.
sudo apt install -f ./rstudio-2022.12.0-353-amd64.deb
Once the installation is finished, you can launch R studio from the applications menu.
Conclusion
That’s it! You have now successfully installed R on your Ubuntu system. You can start using R for data analysis and statistical computing right away.
I hope this step-by-step guide has been helpful in installing R on your Ubuntu system. Happy coding!