R
Installing R on Ubuntu in TIDE
R
R is a programming language and free software environment for statistical computing, data visualization, bioinformatics, and data science. Maintained by the R Foundation, it offers extensive package repositories (CRAN) for advanced data manipulation and machine learning.
Installation
You can install R using standard Ubuntu packages or configure the official CRAN repository to ensure access to the latest R release.
Using Standard APT
apt update
apt install -y r-base r-base-devUsing Official CRAN Repository (Latest Release)
To install the latest R 4.x binaries from CRAN:
apt update
apt install -y software-properties-common dirmngr wget
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | gpg --dearmor -o /usr/share/keyrings/cran-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/cran-archive-keyring.gpg] https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" > /etc/apt/sources.list.d/cran.list
apt update
apt install -y r-base r-base-devVerification
Check the installed R version:
Rscript --versionWriting and Running Code
Create an R script file named hello.R:
cat("Hello from R in TIDE!\n")Running the Script
Execute the script non-interactively using Rscript:
Rscript hello.RInteractive R Console
Start the interactive R console:
RTo quit the interactive R session, type q() and press Enter.
Installing CRAN Packages
Inside the interactive R console or script, install packages using install.packages():
install.packages("ggplot2")