Chapter 0 · Getting Started

The toolchain, before the statistics

Nothing in this course is hard to install, but everything in it is easier once installed properly. Spend an evening on this page and you will not lose a lab to a missing package.

Choose your track

You need one language, not two. Both tracks cover identical material; the tabs on every chapter page exist so that your choice never limits what you can read.

Install in this order:

  1. R (4.3 or newer) from CRAN.
  2. Positron from positron.posit.co — the IDE used in class. RStudio works equally well if you already have it.
  3. Quarto from quarto.org, for reproducible documents and slides.

Then install the packages the course leans on:

install.packages(c(
  "tidyverse",    # data manipulation and graphics
  "tidymodels",   # modelling workflow
  "ISLR2",        # the textbook's datasets
  "glmnet",       # ridge, lasso, elastic net
  "rpart", "rpart.plot",   # trees
  "randomForest", "ranger", "xgboost",
  "boot", "leaps", "pls",
  "MASS", "class", "e1071"
))

Install in this order:

  1. Python 3.11 or newer, most easily via Miniconda or uv.
  2. Positron or VS Code, with the Python and Jupyter extensions.
  3. Quarto from quarto.org.

Then the packages:

pip install numpy pandas matplotlib seaborn scikit-learn statsmodels \
            ISLP jupyter xgboost

ISLP is the textbook’s own Python companion package. It carries the datasets used throughout the labs, which saves a great deal of hunting.

Project structure

Every lab in this course assumes the same shape, and so should your own work:

project/
├── data/          raw data, never edited by hand
├── R/  or  src/   scripts and functions
├── outputs/       figures and tables the code produces
└── report.qmd     the document that ties it together

The rule behind it is simple: if you deleted everything except data/ and the code, one command should rebuild the rest. Anything you cannot rebuild that way is not yet reproducible.

The textbook

NoteCore text

James, Witten, Hastie and Tibshirani (2021), An Introduction to Statistical Learning, 2nd edition. Both the R and Python editions are free to download from statlearning.com. The chapter numbering on this site follows the book.

Reference material in this repository

A working habit

Write code that a stranger could run. In practice that means: no absolute paths, no manual steps hidden between chunks, and a fresh session before you submit anything. The stranger, six months from now, will be you.

Back to top