Back to Course
Setup

Environment Setup

Before you can write a single line of R code, you need to set up your development environment. This involves installing R itself (the language engine) and RStudio (the IDE that makes working with R dramatically easier).

Production Reality: R and RStudio are two separate installations. R is the engine that executes your code; RStudio is the friendly interface you use to write and run it. You need both.

1. System Requirements

RequirementDetails
Operating SystemWindows 10/11, macOS 11+, or Linux (Ubuntu 20.04+)
RAMMinimum 4GB (8GB+ recommended for larger datasets)
StorageAt least 2GB free for R, RStudio, and packages
InternetRequired to download R, RStudio, and CRAN packages

2. Installing R

Step 1: Download R

Visit cran.r-project.org and choose your operating system (Windows, macOS, or Linux).

Windows

  1. Click "Download R for Windows" → "base" → "Download R x.x.x for Windows".
  2. Run the .exe installer and follow the setup wizard using default options.

macOS

  1. Click "Download R for macOS" and select the .pkg file matching your chip (Intel or Apple Silicon).
  2. Open the package and follow the installer.

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install --no-install-recommends r-base

3. Installing RStudio Desktop

Visit posit.co/download/rstudio-desktop and download the free RStudio Desktop edition for your OS. Install it just like any regular application — RStudio will automatically detect your R installation.

Pro Tip: Always install R first, then RStudio. RStudio is just an interface — it looks for an existing R installation on your machine.

4. Verifying Your Installation

Open RStudio and type the following in the Console pane, then press Enter:

print("Hello, R!")
R.version.string

You should see the greeting printed along with your installed R version, e.g. "R version 4.4.1 (2024-06-14)".

5. Installing Essential Packages

R's real power comes from its package ecosystem. Install the most commonly used packages for this course using install.packages():

install.packages("tidyverse")   # dplyr, ggplot2, tidyr, readr, and more
install.packages("shiny")       # interactive web apps
install.packages("rmarkdown")   # dynamic reports
install.packages("caret")       # machine learning workflows
install.packages("plotly")      # interactive charts

Load a package into your session with library():

library(tidyverse)
Common Issues: If install.packages() fails on Linux, you may need system libraries first, e.g. sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev.

6. Setting a CRAN Mirror

On first use, R may ask you to choose a CRAN mirror (download server). Choose one close to your location, or use the global cloud mirror which auto-routes you:

options(repos = c(CRAN = "https://cloud.r-project.org"))

7. Production-Ready Checklist

  • ✅ Install R — Latest stable release from CRAN.
  • ✅ Install RStudio Desktop — Free open-source edition.
  • ✅ Verify installation — Run a test command in the Console.
  • ✅ Install tidyverse — The foundation for data wrangling and visualization.
  • ✅ Set a CRAN mirror — For fast, reliable package downloads.
Pro Tip: Once R prints your test message and tidyverse loads without errors, your environment is production-ready for this entire course.

Ready to master R Programming?

Build real-world data analysis and visualization projects with hands-on training, mentor-led sessions, and placement support.

Explore Course