Course slides
Make your research easier to re-run, understand and share.
Do it together. Then try it yourself.
1 · Structure Where does everything go? Raw data, processed data, code and outputs, and never editing the raw data Hands-on: rescue a messy project
2 · Documentation How do I explain it, and report on it? A README, a data dictionary, and Quarto: one document, many formats Hands-on: be the new colleague, render a document
3 · Environments Will it run on another computer? Why environments matter, and how a lock file lets you send a project that works Hands-on: the new laptop test
4 · Your first step What will you do next? Pull it together into a checklist for your own project Hands-on: your checklist
How should I organise a project so I, and others, can find things and re-run them?
Future you Code written as if others will use it is easier to return to after a holiday, or in six months’ time
Speed A project set up as a pipeline can be re-run quickly when the data changes or a reviewer asks for something new
Confidence You understand how the pieces fit together, and where things might go wrong
Sharing and careers Journals and funders increasingly expect shared code and data, and tidy work is easy to trust
Raw data → Clean → Analyse → Results
Together 4 min
messy-project/
Copy of data.csv notes.txt
analysis.R plot1.png
analysis2 (copy).R plot_new.png
analysis_OLD.R report_draft.docx
clean.R results.xlsx
data.csv results_v3.xlsx
data_FINAL_USE_THIS.csv untitled.R
data_final.csv
data_final_v2.csv
1
Which file is the raw data?
2
What do I run first?
3
Which figure came from which analysis?
Your turn 6 min
On your own, put every file under one heading:
Raw data Cleaned data Code Results Documents
Copy of data.csv notes.txt
analysis.R plot1.png
analysis2 (copy).R plot_new.png
analysis_OLD.R report_draft.docx
clean.R results.xlsx
data.csv results_v3.xlsx
data_FINAL_USE_THIS.csv untitled.R
data_final.csv
data_final_v2.csv
Then decide: which file would you never edit, and which would you delete?
Answer 4 min
| Files | What to do | |
|---|---|---|
| Raw data | data.csv |
Never edit it |
| Cleaned data | data_final.csv, data_final_v2.csv, data_FINAL_USE_THIS.csv |
Three versions of one thing: make it from the raw data with code |
| Code | clean.R, analysis.R, analysis2 (copy).R, analysis_OLD.R, untitled.R |
One script per step, numbered. Delete the copies |
| Results | plot1.png, plot_new.png, results.xlsx, results_v3.xlsx |
The code can re-make these |
| Documents | notes.txt, report_draft.docx |
Become the README and the report |
| Delete | Copy of data.csv |
A duplicate |
Answer 2 min
| File or folder | What it is |
|---|---|
tidy-project/ |
|
├── README.md |
How to run it |
├── report.qmd |
The report |
├── _quarto.yml |
Report settings |
├── data/ |
|
│ ├── raw/penguins.csv |
The original data: never edited |
│ └── processed/ |
|
│ ├── penguins_clean.csv |
Made by the code |
│ └── penguins_clean_dictionary.csv |
Explains each column |
├── code/ |
|
│ ├── 01_clean_data.R |
Numbered, in the order to run them |
│ └── run_all.R |
Rebuilds everything |
└── outputs/ |
Made by the code: safe to delete |
How do I explain my project, and report on it, so others (and future me) can use it?
| Comments in code | Files in the repo | Data dictionary | External documentation | |
|---|---|---|---|---|
| Where | Scripts and notebooks | README.md |
A CSV next to the data | A website or report |
| Why | Explain why, not what | How to use the project | What each column means | What you did, in plain terms |
| Who for | Other researchers | People running your code | Anyone using the data | Less technical readers |
| Example | # outliers removed, as agreed with the lab |
Quickstart and setup | bill_len: bill length, in mm |
A Quarto report |
Write for the person who will read it, which includes yourself!
Using AI
Be careful getting an LLM to create your README. While it can save time, you may inadvertently upload all your data and results by giving access to your folders! Instead, draft one yourself and then use a chatbot to help refine it!
✔ No code? A README is still the best way to document your project
Together 2 min
messy-project/notes.txt is the only documentation:
You have inherited this project. What can’t you work out?
Your turn 4 min
Write down three things you need to know to work on this project.
Think about:
Answer 2 min
# Penguin body mass analysis
Body measurements of 333 penguins on three islands. **Status:** complete.
## Quickstart
1. Open this folder in RStudio or Positron
2. Run `code/run_all.R`
## Setup
- R 4.3 or later
- Quarto 1.4 or later
## Contents
- `data/raw/` the original data (never edited)
- `data/processed/` cleaned data, and a data dictionary
- `code/` the scripts
- `report.qmd` the reportAnswer 2 min
| column | type | description | units / values |
|---|---|---|---|
species |
text | Penguin species | Adelie, Chinstrap, Gentoo |
bill_len |
number | Bill length | mm |
body_mass |
number | Body mass | grams |
sex |
text | Sex of the penguin | female, male |
report.qmd → HTML PDF Word
No copy and paste Numbers, tables and figures come straight from the code, so they can’t drift out of sync with the analysis
Always up to date If the data changes, render again and the whole report updates
One source, many outputs The same file can make HTML, PDF, Word, slides and websites
Plain text Easy to share, compare and keep in version control, in any editor
Without Quarto
With Quarto
1 · Header
The title and the output format
2 · Text
Ordinary Markdown, with headings and lists
3 · Code chunk
The code runs when you render, and its output appears underneath
4 · Inline code
A result inside a sentence, recalculated every time
New data → Re-run the code & Render → Updated report
✔ Change the data (or the code), not the report
Live demo 4 min
Together 6 min
report.qmd → HTML PDF Word
One file. Three formats.
The PDF is made with Typst, so you don’t need LaTeX.
Your turn 7 min
one-document/report.qmdPress Render (choose the format), or run quarto render report.qmd to make all three. Not working? Open the files in finished/.
Answer 3 min
Reports HTML, PDF and Word, with numbered figures, tables and equations that you can cross-reference, and citations
Slides This deck is a Quarto presentation
Websites This course website is built with Quarto
Papers and books Journal articles, theses and books, built from several files
How do I make sure my code still runs next month, or on someone else’s computer?
Your computer has one shared set of packages, so two projects that need different versions can’t both be happy
Packages change Functions are renamed, defaults change and bugs are fixed
Your code depends on them The same code with a different package version can give a different result
Other computers differ A colleague, a new laptop or an HPC: “it works on my machine”
Nothing records it Your project doesn’t say which versions it needs, so nobody can tell what went wrong
Without environments
One shared library of packages for every project on your computer
With environments
Each project has its own set of packages, at the versions it needs
Project 1 → package v1.2
Project 2 → package v1.3
Lock file → Create the environment → Packages installed
| Python | R | |
|---|---|---|
| Tool | uv |
renv |
| Lock file (keep it) | uv.lock |
renv.lock |
| Environment (disposable) | .venv |
renv/library |
| Rebuild it | uv sync |
renv::restore() |
Your project +
lock file → Colleague rebuilds
the environment → Same packages,
same results
✔ Send: your code, README and lock file (and the data, if you can)
✘ Don’t send: the environment itself. It is large, and specific to your computer
uv can pin Python; renv records the R version but doesn’t install it)Good enough for almost every project. Perfect is not the goal!
Write a list of programs
Record the versions
List your plugins
Note your operating system
All of this can live in your README: the next person then knows what you used!
Live demo 5 min
Together 2 min
A colleague emails you their project: “It runs fine on my laptop!”
You open it on your laptop:
Error: there is no package called 'ggplot2'
What would you need to know to make it run?
Your turn 6 min
On your own, list everything you would need to know to run this project on a new computer.
Write down as many things as you can. There is no wrong answer.
Answer 3 min
| You need to know | Where it should be written down |
|---|---|
| Which software, and which version | The README (Setup) |
| Which packages, and which versions | A lock file |
| Where the data is | The README, and a data/raw folder |
| What to run, and in what order | The README (Quickstart), or one script |
| Where the results come from | The code, not copy and paste |
What will you do differently on Monday?
Together 3 min
Messy → Tidy → Documented →
Reported → Recorded → Shareable
Your turn 6 min
Tick what you do. Circle one to start. Post it in the chat.
Structure
☐ Raw data never edited
☐ Separate folders
☐ Clear file names
Documentation
☐ A README
☐ A data dictionary
☐ A report made from code
Environments
☐ Software versions written down
☐ Packages recorded in a file
☐ A colleague could run it
Sharing
☐ Data in an open format (CSV)
☐ A licence
☐ Somewhere to deposit it
Answer 3 min
| Quick win | Time | Why it helps |
|---|---|---|
| Stop editing the raw data | 0 min | Everything can be re-made |
| Clear folders and file names | 15 min | You can find things |
| Write a README | 15 min | Others, and future you, can run it |
| Write down your software versions | 5 min | It runs on another computer |
| Describe your columns | 20 min | Your data makes sense to others |
A project that does all of this is already most of the way to reproducible
Questions?
Sharing your data: Q-FAIR
Quality Accurate, complete, documented
Findable Clear names and description
Accessible Clear how to get it
Interoperable Open, standard formats
Reusable Documented, with a licence
Read more: the FAIR principles
| What to do | Learn more | |
|---|---|---|
| Open formats | Share data as CSV, not a format that needs one program | Turing Way: research data management |
| Describe it | Write a data dictionary: what each column means, its units and missing values | See section 2 |
| Add a licence | Data: CC BY 4.0. Code: MIT | Creative Commons chooser, choosealicense.com |
| Deposit it | A repository that gives a DOI, such as Zenodo or your institution’s | Zenodo |
Can’t share the data? Share the README and data dictionary, and explain how to ask for access
Your turn 4 min
A A spreadsheet called final_data_v7.xlsx on my laptop. Email me if you want it. I would have to remember what some of the columns mean.
B A CSV in a repository, with a DOI, a README, a data dictionary and a CC BY licence.
C A CSV on the department shared drive, with a README. No licence, and you need to ask the group’s admin for access.
For each one, mark every letter of Q-FAIR with a ✔ or an ✘.
Answer 2 min
| Q | F | A | I | R | |
|---|---|---|---|---|---|
| A The spreadsheet | ✘ | ✘ | ✘ | ✘ | ✘ |
| B The repository CSV | ✔ | ✔ | ✔ | ✔ | ✔ |
| C The shared-drive CSV | ✔ | ✘ | partly | ✔ | ✘ |
C is documented (Q) and in an open format (I), but hard to find (F), needs permission (A), and has no licence (R).

Jean Golding Institute © CC-BY 4.0