Setup Guide: Software for the Tutorials
Before You Begin
Lecture 1 explains why we work inside a project environment. This guide gives the commands that set one up. Work through it once, before the first tutorial, on the machine you will use all term.
| Master’s programme | Language | Follow |
|---|---|---|
| Economics | R | The R Route |
| Entrepreneurship | R | The R Route |
| Finance: Financial Management | R | The R Route |
| Finance: Sustainable Finance and Investments | R | The R Route |
| Finance: Banking and Finance | Python | The Python Route |
Installation is the one part of this course that can fail for reasons that have nothing to do with econometrics. Do it before the tutorial, not during it. If something breaks, note the exact error message: it is almost always enough to find the answer.
Everything here has a counterpart in the other language. Once your own setup works, skimming the other route shows you how the same ideas are expressed elsewhere.
The R Route
Step 1: Install R, Then RStudio
Install R first. R is the language itself. Then install RStudio Desktop, which is the editor you work in.
The order matters: RStudio looks for an R installation when it first starts. Once both are installed, open RStudio and check the Console, which prints the R version at startup.
Installing RStudio does not install R. If RStudio reports that it cannot find an R installation, R itself is missing.
Step 2: Install the Course Packages
Run this once, in the RStudio Console:
install.packages(c("tidyverse", "here"))install.packages() downloads from CRAN and copies the package onto your disk. You never need to run it again for that package on that machine. Installing can take a few minutes, since the tidyverse is many packages at once.
Load them at the start of every session:
library(tidyverse)
library(here)The distinction matters:
install.packages()is buying the book. It is permanent.library()is taking it off the shelf and opening it.
A fresh R session starts with an empty shelf, which is why every script begins with its library() calls.
Error in library(tidyverse) : there is no package called 'tidyverse'
means the package was never installed. Run install.packages("tidyverse") once, then library(tidyverse) again.
The :: Notation
here::here() means: the function here() from the package here. You will see this notation constantly, including throughout this site, because it works without loading the package first.
# These two are equivalent, given that here has been installed:
library(here)
here("data", "raw")
here::here("data", "raw")Use :: when you want to be explicit about where a function comes from.
Step 3: Create an RStudio Project
An RStudio Project is a folder with an .Rproj file in it. Opening that file sets R’s working directory to the project folder, which is what makes paths work on any machine.
In RStudio: File → New Project → New Directory → New Project, then give it a name.
empirical_economics/
├── empirical_economics.Rproj
├── data/
│ ├── raw/
│ └── processed/
├── code/
└── output/
Always open the project by double-clicking the .Rproj file, not by opening a loose script.
Inside a project, here() builds paths from the project root:
library(here)
macro <- read_csv(here("data", "raw", "macro.csv"))The same line works on Windows, macOS, and Linux, and in the exam environment.
setwd("C:/Users/yourname/Documents/...") hard-codes a path that exists only on your computer. Nobody else, including a grader, can run that script.
Step 4 (Optional): renv for Reproducibility
install.packages() puts packages in one shared library for your whole machine, so updating a package for one project changes every project. renv gives a project its own private library instead.
install.packages("renv")
renv::init() # give this project its own library
renv::snapshot() # record exact versions in renv.lock
renv::restore() # rebuild that library on another machineThis is not required for the course, but it is the R answer to the same problem uv solves in Python.
R Setup Checklist
Open RStudio through your .Rproj file and run:
library(tidyverse)
library(here)
here() # should print your project folder
mean(c(2, 4, 6)) # should print 4If all of these run without error, your R setup is complete.
The Python Route
Banking and Finance students use the shared USE Python repository for both Empirical Economics (USEMEE) and Financial Data Analytics (USEMFDA). Its pyproject.toml and uv.lock are the authoritative package configuration for this class. Do not create a separate Empirical Economics environment.
If you already set up use-python for Financial Data Analytics, keep that same folder and continue at Step 2.
Step 2: Double-Click to Start JupyterLab
- Windows: double-click
start-jupyterlab.bat. - macOS: double-click
start-jupyterlab.command. If macOS blocks it the first time, right-click (or Control-click) it, choose Open, and confirm. If needed, use System Settings → Privacy & Security → Open Anyway.
The launcher checks for uv and installs it automatically when necessary. It then installs the required Python version and all packages from the shared configuration before opening JupyterLab in your browser. You do not need to install Python, uv, or an editor separately.
The first start downloads Python and all course packages, which can take several minutes. Do not close the black or Terminal window. Later starts should take only a few seconds.
Keep that window open while you work. To stop JupyterLab, return to it and press Ctrl+C, then close the window.
Step 3: Check That It Works
In JupyterLab’s file browser, open USEMEE/notebooks/, create a Python notebook, and run:
import pandas as pd
import statsmodels.api as sm
pd.Series([2, 4, 6]).mean()If the cell runs and prints 4.0, your Python setup is ready.
Working in JupyterLab
Keep one notebook per tutorial or project in USEMEE/notebooks/. Tutorial data are loaded directly from the course website, so the same code works on every machine:
import pandas as pd
df = pd.read_stata("https://empirical-economics.netlify.app/tutorials/datafiles/SLEEP75.DTA")Everything required by the two courses is already included. Do not modify pyproject.toml or install packages yourself with uv add, !pip install, or %pip install. If a required package is missing, ask the instructor to add it to the shared repository so everyone receives the same environment.
Visual Studio Code Is Optional
JupyterLab is the default. If you prefer Visual Studio Code, double-click start-vscode.bat on Windows or start-vscode.command on macOS. The launcher opens the correct shared folder and helps you obtain VS Code if it is missing. Install Microsoft’s Python and Jupyter extensions, and use the interpreter from the use-python environment.
Reference
The Two Routes Side by Side
| Task | R | Python |
|---|---|---|
| Where you work | RStudio | JupyterLab |
| Install a package | install.packages("x") |
Ask the instructor to update the shared configuration |
| Load it in a script | library(x) |
import x |
| Project marker | project.Rproj |
pyproject.toml |
| Build a path | here("data", "raw") |
Path("data") / "raw" |
| Pin versions | renv::snapshot() |
uv.lock (automatic) |
| Rebuild elsewhere | renv::restore() |
Run the use-python launcher |
The commands differ; the problems they solve are identical.
If Something Goes Wrong
Read the exact error message and search for it. Most setup errors are common and well documented. Then check the obvious:
- Did you open the project (the
.Rprojfile, or JupyterLab via the launcher insideuse-python)? A Jupyter or Python installed outside the shared environment counts as the wrong door. - For R, did you install the package? In either language, is this a fresh session that still needs
library()orimport? Python students should ask the instructor about a missing package rather than install it themselves.
Bring the error message to the tutorial. A screenshot of the message is worth more than a description of it.
Where to Read More
- R for Data Science (2e): tidyverse workflows
- RStudio User Guide: projects and the IDE
- renv documentation: reproducible R libraries
- uv documentation: Python environments and packages
- USE Python repository: the shared Python environment and its current setup instructions
- JupyterLab user guide: finding your way around JupyterLab
- pandas Getting Started: pandas workflows