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:
- R (4.3 or newer) from CRAN.
- Positron from positron.posit.co — the IDE used in class. RStudio works equally well if you already have it.
- 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:
- Python 3.11 or newer, most easily via Miniconda or uv.
- Positron or VS Code, with the Python and Jupyter extensions.
- Quarto from quarto.org.
Then the packages:
pip install numpy pandas matplotlib seaborn scikit-learn statsmodels \
ISLP jupyter xgboostISLP 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
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
- R introduction (PDF) — a short refresher on the language
- Introduction to ISLR (DOCX) — course orientation notes
- Introduction slides (PDF) — the opening lecture handout
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.