R
Ubuntu
Install
# With the deprecation of apt-key, the recommended method for adding the key is:
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
# To verify the key:
gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# The fingerprint should be E298A3A825C0D65DFD57CBB651716619E084DAB9.
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/"
sudo apt update
sudo apt install r-base
sudo apt install ./rstudio-2024.12.1-563-amd64.deb
CLI
| command | description |
|---|---|
R | starts an R interactive shell session |
R --version |
R
Interactive Shell
| command | description |
|---|---|
q() | exit the shell session |
save.image(file='yoursession.RData') | save all environment data into an .RData file |
load('yoursession.RData') | load all environment data from an .RData file |
Setup
pak - A Faster Way to Install R Packages
The {pak} package is a modern tool that makes installing packages quicker and more reliable. It automatically handles dependencies and works well on any operating system.
To use {pak}, first install it:
install.packages("pak")
Then, install any package with:
pak::pkg_install("readr")
You can install multiple packages at once, too:
pak::pkg_install(c("readr", "ggplot2", "tidyr"))
The {pak} package is a great option when you’re setting up a new R environment or managing multiple packages.
packages
| command | description |
|---|---|
install.packages('tidyverse') | install package tidyverse |