How To Install R Programming Language on Debian 12
In this tutorial, we will show you how to install R Programming Language on Debian 12. The R programming language is a statistical computing and graphics powerhouse that has become the go-to tool for data analysis, visualization, and statistical modeling.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of R Programming Language on a Debian 12 (Bookworm).
Prerequisites
- A server running one of the following operating systems: Debian 12 (Bookworm).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- Make sure your Debian 12 system is connected to the internet. An active connection is essential for downloading the required packages and updates during the installation.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install R Programming Language on Debian 12 Bookworm
Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt
commands in the terminal:
sudo apt update sudo apt upgrade
This command updates the package list and upgrades the installed packages to their latest versions.
Step 2. Adding the CRAN Repository.
The Comprehensive R Archive Network (CRAN) is the backbone of the R ecosystem. It’s a network of servers worldwide that store R packages and their documentation. To access R and its packages, we need to add the CRAN repository to Debian:
sudo nano /etc/apt/sources.list
Append the following line at the end of the file:
deb https://cloud.r-project.org/bin/linux/debian bookworm-cran40/
Add the CRAN GPG key to verify packages. Execute the following commands:
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 0x51716619E084DAB9 sudo apt update
Step 3. Installing R Programming Language on Debian 12.
Debian makes it relatively easy to install R using the APT package manager. It’s a straightforward process. Execute the following command to install R:
sudo apt install r-base
If you’re planning to develop R packages or extensions, you may want to install additional development tools:
sudo apt install r-base-dev
It’s essential to verify that R has been installed without any issues. You can do this by opening the R console:
R
Inside the R console, check the R version:
R.version.string
To exit the R console, use the q()
command:
q()
Now, R is up and running on your Debian 12 system. If you’re looking for a more feature-rich development environment, consider installing RStudio (which is optional).
Step 4. Installing RStudio on Debian (Optional).
RStudio is an Integrated Development Environment (IDE) designed specifically for R. It offers a range of features that enhance your R programming experience. Go to the RStudio Download Page and select the RStudio version appropriate for your system. Choose the “Debian-based” option:
sudo dpkg -i rstudio-x.yy.zzz-amd64.deb
Make sure to replace x.yy.zzz
with the actual version number in the filename.
If any dependencies are missing, the dpkg
command may return an error. You can fix this by running:
sudo apt --fix-broken install
Once the installation is complete, you can access RStudio from your applications menu or by running rstudio
from the terminal.
Step 5. Managing R Packages.
Once you have R installed, managing packages is crucial for expanding its functionality. Here’s how you can install, update, and remove R packages.
To install an R package, open your R console and run:
install.packages("package_name")
You can update packages to their latest versions with:
update.packages()
To remove a package, use:
remove.packages("package_name")
Congratulations! You have successfully installed R Programming Language. Thanks for using this tutorial to install the latest version of R Programming Language on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official R Programming Language website.