Installing R & RStudio

By the end of this lesson you'll have R - the language statisticians and biologists reach for - plus RStudio, the friendly workspace that makes it a pleasure to use.

🟒 Beginner ⏱️ ~30 min πŸ“Š R πŸ’» Windows Β· macOS Β· Linux

Two pieces, and why

You install two things. R is the actual language and engine. RStudio is the workspace you'll spend your time in - it gives you a code editor, your plots, your data, and your console all in one window. R is the car; RStudio is the comfortable dashboard. Install R first, then RStudio.

Why R for bioinformatics?

R was built by statisticians, and the gold-standard tools for RNA-seq, differential expression, and genomics - DESeq2, edgeR, limma, and the whole Bioconductor project - live in R. If you want to work with expression data, R is unavoidable, and that's a good thing.

Step 1 - Install R (from CRAN)

R is distributed by CRAN (the Comprehensive R Archive Network) at cran.r-project.org. Pick your OS:

πŸͺŸ Windows Windows 10/11

  1. Go to cran.r-project.org β†’ "Download R for Windows" β†’ "base" β†’ "Download R for Windows".
  2. Run the .exe installer and accept the defaults.

🍎 macOS Intel & Apple Silicon

  1. Go to cran.r-project.org β†’ "Download R for macOS".
  2. Pick the right .pkg: arm64 for Apple Silicon (M1-M4), or the Intel build for older Macs.
  3. Open the .pkg and follow the installer.

🐧 Linux Ubuntu / Debian

The quickest route on Ubuntu/Debian:

sudo apt update
sudo apt install r-base

For the very latest R, CRAN has per-distro instructions at cran.r-project.org/bin/linux. On Fedora, use sudo dnf install R.

Step 2 - Install RStudio Desktop (free)

Go to posit.co/download/rstudio-desktop and download the free RStudio Desktop for your OS. It will detect the R you just installed automatically.

  • Windows: run the .exe installer.
  • macOS: open the .dmg and drag RStudio into Applications.
  • Linux: download the .deb (Ubuntu/Debian) or .rpm (Fedora) and install it.

Step 3 - Check it worked

Open RStudio. In the Console pane (bottom-left), type this and press Enter:

R.version.string
# [1] "R version 4.x.x ..."
1 + 1
# [1] 2

If R answers, you're in business. πŸŽ‰

Step 4 - Install your first packages

Packages add features. We'll grab the tidyverse (the modern toolkit for data work) and palmerpenguins (a friendly real dataset we'll use in the project). In the Console:

install.packages("tidyverse")
install.packages("palmerpenguins")

This downloads from CRAN and can take a few minutes the first time - that's normal. Say "yes" to any prompts.

Decode the jargon: Bioconductor

CRAN is R's general package store. Bioconductor is a second store dedicated to biology - it's where DESeq2 and friends live. You install from it a little differently (BiocManager::install("DESeq2")). You don't need it yet, but now the name won't surprise you when it shows up in Track 3.

βœ… You're ready when…

RStudio opens, 1 + 1 returns 2 in the Console, and library(tidyverse) runs without an error. On to the basics.

Stuck? Common snags

RStudio says it can't find R

This happens if RStudio was installed before R, or you have multiple R versions. In RStudio go to Tools β†’ Global Options β†’ General β†’ and set the R version, or simply reinstall R then restart RStudio.

install.packages fails with a "non-zero exit status" on Linux

Some R packages need system libraries to compile. The error usually names what's missing (e.g. libcurl, libxml2). Install the matching -dev package with apt (e.g. sudo apt install libcurl4-openssl-dev) and try again.

Check your understanding

Where do you download R itself from?
What is RStudio?
What does the lesson say RStudio adds on top of R?
R is the engine and RStudio is the workspace around it, giving you the editor, plots, data, and console together; the lesson calls R the car and RStudio the dashboard.
In what order does the lesson tell you to install the two pieces?
You install R first so RStudio can detect it automatically when you install RStudio afterward.
Which command installs an R package such as the tidyverse from CRAN?
Inside the RStudio Console you run install.packages("tidyverse"), which downloads and installs the package from CRAN.
Next in the R series

R basics: data frames & plotting β†’