Or copy link
Copy link
R is a popular language for statistical analysis and data visualization, essential for both professionals and enthusiasts. R offers tools for statistical analysis, customizable graphics, and access to more than 15,000 packages available on CRAN. It is open-source, integrates with various languages and databases, and can be used with IDEs like RStudio for an improved coding experience.
You can install R on Ubuntu either from the default Ubuntu repositories or the CRAN repository. The default Ubuntu repository is simple but may provide an older version while CRAN offers the latest R version but requires a few extra steps. In this article, we will show you both these methods to install R language on Ubuntu 24.04.
To install R on Ubuntu, first, update the packages list, then install R along with the required dependencies, and finally verify the R installation on Ubuntu:
Let’s update the apt packages list before starting the R installation on Ubuntu:
sudo apt update
Before installing R on Ubuntu, it’s recommended to check your Ubuntu version to avoid compatibility issues with the R packages and repositories.
After updating system packages, run the following command to install R from the Ubuntu repository along with the required dependencies:
sudo apt install r-base r-base-dev -y
To confirm the R installation on Ubuntu, simply type R on the terminal and hit the enter key:
R
This command will open the R console if R is installed. Moreover, it shows the version information and a prompt (usually >). However, if R is not installed, you’ll see a message like “command not found”, which means R isn’t available on your system:
You can type q() at the R prompt to quit the session, after which R will prompt you to save the workspace before exiting.
Install R Language on Our Ubuntu VPS!
Install R on our Ubuntu VPS to use powerful statistical analysis and data visualization capabilities, enhancing your data-driven projects.
CRAN is the primary repository for R, maintained by the R Foundation, and includes current and past versions along with contributed packages. To install R on Linux from the CRAN repository, you must go through the following steps:
Let’s update system repositories to make sure we get the latest version of R:
Run the following command to install software-properties-common for managing software repositories and dirmngr for handling certificates and secure connections:
sudo apt install software-properties-common dirmngr -y
Now, run the following command to download the GPG key for CRAN from the specified URL and add it to your trusted keys in the Ubuntu 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
You can check the CRAN repository key fingerprint by verifying the downloaded key with the following command:
gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
Now add the CRAN repository to your system, using lsb_release -cs to automatically insert your Ubuntu distribution’s codename and ensure the correct repository is included:
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
Now you’re all set to install the base R package and its dependencies from the CRAN repository. For this purpose, you can execute the following command from the terminal:
The r-base-dev package offers the essential tools needed to compile and install R packages from source via the install.packages() function.
Read also How to Install Java on Ubuntu 22.04
Finally, you can confirm the R language installation on your Ubuntu machine using the following command:
R has thousands of packages created by its community for tasks like data visualization, machine learning, statistical modeling, and text mining. Among them, the most widely used are listed below:
You can install R packages directly from the R console by using the install.packages(“package_name”) function. For instance, the following command installs the data.table package from the CRAN repository:
install.packages("data.table")
After installing the package, you can use/load the package using the below-given syntax:
library("package_name")
Similarly, you can verify the package’s installation by listing all the installed packages using the following command:
installed.packages()[,1]
This is how you can install and start using the R language on Ubuntu.
R is free, open-source software used for statistical computing and graphics. You can install R on Ubuntu using either the default Ubuntu repository or the CRAN repository. The Ubuntu repository simplifies the process, while CRAN provides the latest version of R with a few extra steps. After installation, you can manage R packages easily through the R console, giving you access to powerful tools for data analysis and visualization. In this article, we discussed how to install the R language on Ubuntu using step-by-step instructions.
We hope this guide has assisted you in installing R on Ubuntu 24.04. Setting up R on a Linux system is straightforward with the right hosting platform. Ultahost’s Linux VPS hosting is an excellent choice, providing fast performance and the flexibility to scale resources as your data analysis projects expand.
R is a popular language for statistical analysis and data visualization, widely used by both professionals and enthusiasts.
Yes, R is free and open-source software, making it accessible to everyone for statistical computing and data visualization.
You can install R on Ubuntu either from the default Ubuntu repository or the CRAN repository.
To check if R is installed, simply enter “R” in the terminal. If R is installed, the R console will open with version information.
You can install R packages directly from the R console using the install.packages(“package_name”) command.
Using CRAN ensures you get the latest version of R along with updated features and improvements.
You need to install helper packages like software-properties-common and dirmngr to manage repositories and secure connections before adding CRAN.
Webmin is an open-source tool for Linux distributions t...
When it comes to securely managing sensitive data such ...
MongoDB, the popular NoSQL database, offers a powerful ...
A proxy server acts as an intermediary between a client...
Ubuntu Server is a powerful and flexible operating syst...
Linux is an open-source operating system that offers a ...
Save my name, email, and website in this browser for the next time I comment.
Δ