Packages and Reproducibility
R library() vs. Python import
Both languages require you to load packages before using them.
| R | Python | Purpose |
|---|---|---|
library(readr) |
import pandas as pd |
read CSV files |
library(dplyr) |
import pandas as pd |
filter, group, and summarise data |
library(ggplot2) |
import seaborn as sns |
create plots |
library(reticulate) |
not applicable | call Python from R |
Why requirements.txt Matters
Python projects record package dependencies in requirements.txt. This is the Python-side equivalent of saying, “Here is what another person must install before my code will run.”
The course Codespace already provides pandas and the notebook tools, so you should not need to install anything for this week’s required work. Only edit .devcontainer/requirements.txt if an additional Python package has been approved.
In the course Codespace this file lives at .devcontainer/requirements.txt (at the top level of your project). The file itself is simple — one package name per line. For example, a project that depends only on pandas would contain:
If you also create a plot in Python with packages that are not preinstalled, add:
Course Rule
If you rely on an approved additional Python package, record it in the root .devcontainer/requirements.txt and in your dependency note. Do not create a second submission-folder requirements file.
R Connection
R reproducibility uses the same devcontainer baseline plus explicit library() calls and dependency notes. Week 5 is a bridge: you should be able to explain where dependencies are recorded in both languages.