Skip to main content

Course notes

Author

Jean Golding Institute

Introduction

Welcome to this course! These notes go with the slides. You can use them afterwards to revisit the detail, and you can also work through them on your own: each section ends with a “Try it yourself” activity, with instructions and an answer you can open.

The course introduces practical habits that make your research easier to re-run, understand and share. The course contains examples for both Python and R, with opportunities to include your own code and examples.

By the end of this course you will be able to:

  1. Organise a project into raw data, processed data, code and outputs, and explain why raw data is never edited.
  2. Describe what a good README and data dictionary contain, and why they matter, particularly for Data Management Plans.
  3. Explain why Quarto helps reproducibility, and make HTML, PDF and Word versions of a report from one document.
  4. Explain why environments matter, and say what someone needs in order to re-run your project on another computer.
  5. Apply these practices to your own coding projects, using the R and Python examples as a starting point.
  6. Choose one practice to start using on your own project, and know where to find out more.
How to read this document

Small snippets of code are shown in a grey box like this:

cat("Hello!")

When the code is run, its output is shown below it, marked with a vertical red line:

cat("Hello!")
Hello!

Larger pieces of code are shown as scripts with a filename:

script.R
name <- "Jean Golding"
cat("Hello,", name, "!")

Commands to run in a terminal look like this:

Terminal/Command Prompt
Rscript script.R

In each section there is a “Try it yourself” activity, which is also on the slides. Activities are shown in a box with a red top edge, and each one ends with a yellow box that contains the answer. Try each one yourself before looking at the answer.

An example activity

This is an exercise. Click the box below to see the answer.

This is the answer.

Important points are highlighted in green boxes like this one:

TipKey points

These are important concepts and technical notes.

Workspace setup

The live activities don’t need you to write or run any code: the only thing you run is Render. You need two things.

Quarto. We use Quarto to build documents. RStudio and Positron include it, so if you use either you probably don’t need to install anything. To check, open a .qmd file and look for the Render button. Otherwise, install Quarto for your operating system (VS Code users also need the Quarto extension). Use version 1.4 or later: quarto --version in a terminal shows which you have.

The example folder. Download the example folder and unzip it. It has five folders, and the checklist:

Folder What it is
messy-project/ A project with a bad structure and bad names
tidy-project/ The same project with all the good habits
one-document/ A short report to turn into HTML, PDF and Word
environment-demo/ A small project in R (r/) and in Python (python/), for trying environments with renv or uv (optional)
capstone-answer/ A finished answer to the capstone exercise, in R (r/) and in Python (python/)
checklist.pdf, checklist.docx A one-page checklist for your own project

If you want to do the optional capstone exercise, you will also need R or Python, and uv (Python) or the renv package (R).

1 Project structures

How should I organise a project so that I, and others, can find things and re-run them?

1.1 Why bother?

A project that has grown organically tends to look like a folder full of files called data.csv, data_final.csv, analysis2.R and analysis_NEW.py. This causes three problems:

  • Hard to maintain: one change near the start breaks everything downstream.
  • Hard to run somewhere else: a new laptop, an HPC cluster or a colleague’s machine, and the code breaks.
  • Hard to understand: after a holiday you can’t remember which file to run first.

Making a project more reproducible helps you first and others second:

  • Saving your future self: write code as if someone else will use it, because in six months that someone is you.
  • Speed: a project set up as a pipeline can be re-run quickly when the data or a reviewer’s comment changes.
  • Confidence: you understand how the work fits together, and where it might fail.
  • Publication and jobs: sharing code and data is an increasingly common requirement, and tidy work is easy to trust.
  • Data Management Plans: all data can be found and correctly stored, according to different restrictions.

1.2 A messy project

Open messy-project/ in the example folder. It looks like this:

messy-project/
├── Copy of data.csv
├── analysis.R
├── analysis2 (copy).R
├── analysis_OLD.R
├── clean.R
├── data.csv
├── data_FINAL_USE_THIS.csv
├── data_final.csv
├── data_final_v2.csv
├── notes.txt
├── plot1.png
├── plot_new.png
├── report_draft.docx
├── results.xlsx
├── results_v3.xlsx
└── untitled.R

Questions to ask of this layout:

  • Which file is the raw data?
  • What do I run first?
  • Which figure came from which analysis?

This happens naturally. You start by exploring a dataset in a notebook, a script or an Excel sheet. The analysis grows, then a second analysis is added, and it becomes hard to see how you got from the raw data to the results.

1.3 A tidy project

Now open tidy-project/. It holds the same project, organised:

File or folder What it is
tidy-project/
├── README.md What the project is, and 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 The cleaned data, 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

The key ideas are:

  1. A README at the top of the project says what it is and how to use it (see the next section).
  2. Raw data is read-only. Never overwrite your original data file. Save the cleaned version somewhere else.
  3. Code is a pipeline. Each step reads the output of the previous step: raw data -> clean -> analyse -> results. Numbering the files shows the order to run them in.
  4. Results can be thrown away. Anything in outputs/ and data/processed/ can be re-made by running the code. code/run_all.R does exactly that: delete them, run it, and they come back.

Spreadsheets. The same structure works for spreadsheets:

  • Keep the original file in a data/raw folder and never edit it. Open it, then use Save As to put a working copy in data/processed.
  • Use one sheet per step, in order, and name them (1_raw, 2_cleaned, 3_results) rather than leaving Sheet1.
  • Write down in the README what you did to the data at each step, in enough detail that someone else could repeat it.
  • Put formulas in cells rather than pasting values, so the calculation is visible.
TipYou don’t need everything

How much structure a project needs is a judgement call. A small one-off analysis may not need all of this. Aim for what is useful, not what is perfect.

Try it yourself

Rescue the messy project

Open messy-project/ in the example folder (you do not need to run anything).

  1. Try to answer: which file is the raw data? What do I run first? Which figure came from which analysis?
  2. Put every file under one heading: raw data, cleaned data, code, results, documents.
  3. Decide which file you would never edit, and which files you would delete.
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, with no way to tell which is right. 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

Compare your answer with tidy-project/. To see the “everything can be re-made” idea for yourself, look at tidy-project/code/run_all.R: it deletes the cleaned data and the report, then makes them again from the raw data.

TipKey points
  • Separate raw data, cleaned data, code and results.
  • Never overwrite the raw data.
  • Think of the analysis as a pipeline that can be re-run from start to finish.
  • This applies equally to scripts, notebooks and spreadsheets.

2 Documentation & Quarto

How do I explain my project, and report on it, so others (and future me) can use it?

2.1 Types of documentation

Type Where Why Audience
Comments in code Scripts, notebooks, function docstrings Explain or justify what isn’t obvious from the code Other researchers and developers
Files in the repository README.md Describe how to use the project Developers, and people running the code
Data dictionary A CSV next to the data Explain what each column means, its units and missing values Anyone using the data
External documentation A website or report Describe what you are doing in less technical terms, with quickstart guides Users and less technical readers

A good comment says why, not what. # remove outliers > 3 SD, as agreed with the lab is more useful than # remove outliers.

2.2 README.md

A README is a plain text file in the top folder of the project. It is the first thing someone reads, and it helps you in six months’ time as much as it helps anyone else. It should contain:

  • Summary: what the project is for, and its status (for example ongoing or complete).
  • Quickstart: the most important files, and in what order to run them.
  • Setup: what needs to be installed before running the code.
  • Contents: a description of what each folder holds.

Here is the README from tidy-project/. It is written in Markdown, which is a simple way of marking up text:

# Penguin body mass analysis

Body measurements of 333 penguins on three islands. **Status:** complete.

## Quickstart

1. Open this folder in RStudio or Positron (or a terminal).
2. Run `code/run_all.R`. It cleans the data and builds the report in `outputs/`.

## Setup

- R 4.3 or later (no extra packages needed)
- Quarto 1.4 or later (to make the report)

## Contents

- `data/raw/` the original data (never edited)
- `data/processed/` the cleaned data, and a data dictionary explaining each column
- `code/` the scripts
- `report.qmd` the report, which makes HTML, PDF and Word versions
- `_quarto.yml` settings for the report (it puts the results in `outputs/`)
- `outputs/` made by `run_all.R`. Safe to delete

You can use a README in any project, whether or not you write code. For a spreadsheet project it is the place to record what each sheet does and how the data was collected.

2.3 Data dictionary

A dataset on its own doesn’t explain itself. What does bill_dep mean? Is body_mass in grams or kilograms? Does a blank mean it wasn’t measured? Write this down in a data dictionary, a small table with one row per column:

column type description units / values
species text Penguin species Adelie, Chinstrap, Gentoo
island text Island where the penguin was observed Biscoe, Dream, Torgersen
bill_len number Bill length mm
bill_dep number Bill depth mm
flipper_len number Flipper length mm
body_mass number Body mass grams
sex text Sex of the penguin female, male
year number Year of the study 2007, 2008 or 2009

Save it next to the data (for example data/processed/penguins_clean_dictionary.csv) and refer to it from your README. You can also include a short description of the whole dataset: who collected it, when, how, and any known problems. A dictionary is one of the most valuable things you can write, because only the person who knows the data can.

To make one, copy your column names into a spreadsheet or CSV file, then add columns for the type, a description, and the units or values. Fill them in by hand, and save the file as a CSV next to the data.

2.4 What is Quarto?

Quarto is a free, open-source tool for writing documents that combine text and code. You write one file (report.qmd). When you render it, the code runs, and the results (numbers, tables and figures) are put into a finished document, such as an HTML page, a PDF or a Word file.

Quarto works with R, Python and other languages, from the IDE you already use. The slides, the notes and the website for this course are all made with Quarto.

2.5 Why use Quarto for reproducible research?

A report is often the last step of an analysis, and the easiest place to introduce mistakes: a number is copied from the wrong run, or a figure is from an older version of the data. Quarto removes that step.

  • 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. A .qmd file is easy to share, compare and keep in version control, in any editor.
Without Quarto With Quarto
1 Run the analysis Write the report once, with the code in it
2 Copy numbers and plots into a Word document Render
3 The data changes The data changes
4 Repeat by hand, and hope you caught every number Render again

2.6 Weaving text and analysis together

A Quarto file has four ingredients:

  1. A header with the title and the output format (between two lines of ---).
  2. Text, written in Markdown: headings, paragraphs, lists and links.
  3. Code chunks: R or Python code in a fenced block. When you render, the code runs and its output (a table, a plot) appears underneath.
  4. Inline code: a result inside a sentence, which is recalculated every time you render.
report.qmd
---
title: "Penguin report"
format: html
---

## Data

```{r}
clean <- read.csv("data/processed/penguins_clean.csv")

# keep one species: filter out Adelie and Chinstrap
gentoo <- subset(clean, species == "Gentoo")
```

After removing incomplete rows, there are `{r} nrow(clean)` penguins in the data. `{r} nrow(gentoo)` of them are Gentoo penguins.

## Results

The mean body mass of Gentoo penguins was `{r} round(mean(gentoo$body_mass))` g.

```{r}
boxplot(body_mass ~ sex, data = gentoo, ylab = "Body mass (g)")
```
report.qmd
---
title: "Penguin report"
format: html
---

## Data

```{python}
import pandas as pd

clean = pd.read_csv("data/processed/penguins_clean.csv")

# keep one species: filter out Adelie and Chinstrap
gentoo = clean[clean["species"] == "Gentoo"]
```

After removing incomplete rows, there are `{python} len(clean)` penguins in the data. `{python} len(gentoo)` of them are Gentoo penguins.

## Results

The mean body mass of Gentoo penguins was `{python} round(gentoo["body_mass"].mean())` g.

```{python}
gentoo.boxplot(column="body_mass", by="sex")
```

(The plot needs the matplotlib package.)

Quarto can be used for the written part of a project even if your analysis is in a spreadsheet. Save your final table as a CSV, then include it in the report:

report.qmd
---
title: "Penguin report"
format: html
---

Results from the spreadsheet analysis:

```{r}
knitr::kable(read.csv("outputs/tables/results.csv"))
```

This still needs R installed. If you’d rather not use code at all, a README and clearly labelled sheets are the best documentation you can write.

2.7 When the data changes

Because the numbers in the report come from code, a change in the data flows through to the report:

new data  ->  re-run the cleaning script  ->  render the report  ->  updated report

Every number, table and figure is recalculated, and sentences with inline code update too. There is nothing to copy and paste. This is the main reason to use Quarto for reproducible research: change the data (or the code), not the report.

2.8 One document, many formats

One of the best things about Quarto is that one source file can make several kinds of document. You list the formats you want in the header:

format:
  html: default
  typst: default
  docx: default
  • html makes a web page.
  • typst makes a PDF. Typst comes with Quarto, so you don’t need to install LaTeX.
  • docx makes a Word document.

When you render, Quarto makes all three from the same text, code and figures. Change the title, a sentence or the data once, and every format changes.

To render, press the Render button in your IDE (use the format menu to choose which one), or run this in a terminal to make every format at once:

Terminal/Command Prompt
quarto render report.qmd

2.9 What else can Quarto do?

  • Reports in HTML, PDF and Word, with numbered figures, tables and equations, and citations. You can cross-reference them: write @fig-mass and Quarto writes “Figure 1”, with a link, and keeps the numbers right as you add or move figures. The capstone exercise shows how.
  • Slides: the slides for this course are a Quarto presentation.
  • Websites: this course website is built with Quarto.
  • Papers and books: journal articles, theses and books, built from several files.

2.10 Optional: trying it yourself

The activities in this course don’t need any code. If you want to write a Quarto report with code in it, with numbered sections, a table, a figure, cross-references and a citation, the capstone exercise takes you through it, in R or Python.

2.11 Learn more about Quarto

Try it yourself

Be the new colleague

You have inherited the messy project. Open messy-project/notes.txt: it is the only documentation. Look at the first rows of messy-project/data.csv too.

  1. Write down three things you can’t work out. Think about how to run it, which software it needs, what the columns mean, and which file is the real data.
  2. Open tidy-project/README.md and tidy-project/data/processed/penguins_clean_dictionary.csv. Which of your three things do they answer?

Typical things you can’t work out from the messy project: how to run it and in what order (the notes say “i think”); which software and versions it needs; what bill_dep means and whether body_mass is in grams or kilograms; which data file is the real one; which figure is which.

The README answers how to run it, what software it needs and what is where. The data dictionary answers what each column means, with its type and units. A good README answers three questions in the first minute: What is this project and is it finished? If I just want to run it, what do I do first? What do I need installed?

One document, many formats

You need Quarto, but not R or Python.

  1. Open one-document/report.qmd.
  2. Change the title, the author and one sentence.
  3. Render it as HTML, then PDF, then Word: press Render and choose each format, or run quarto render report.qmd to make all three.
  4. Open all three. Did your changes appear in each?

If Render doesn’t work, open the ready-made files in one-document/finished/.

Your changes appeared in every format, because there is only one source. That is the point: you never copy and paste between a web page, a PDF and a Word file.

If only one format appeared, Render was set to a single format. Use the format menu, or the quarto render report.qmd command, to make all three.

TipKey points
  • Document at several levels: comments, the README, a data dictionary and external write-ups.
  • Every project should have a README, and every dataset a data dictionary.
  • Quarto turns text and code into a report that can be re-created at any time, in several formats.
  • If the data changes, render again and the whole report updates.

3 Virtual environments

How do I make sure my code still runs next month, or on someone else’s computer?

3.1 Why do we need environments?

Imagine this sequence:

  1. Last year you wrote an analysis, and it runs, using version 1.2.1 of a package (here, the R package tidyr).
  2. This year you start a new project that needs version 1.3.1, so you update.
  3. You re-run last year’s analysis, and it breaks, or gives different results.
Old project New project
Program R 4.3.0 R 4.3.0
tidyr 1.2.1 1.3.1
ggplot2 3.3.5 3.5.0

Your computer has one shared set of packages, so two projects that need different versions can’t both be happy. This happens for several reasons:

  • 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 cluster will have different versions installed: “it works on my machine”.
  • Nothing records it. Your project doesn’t say which versions it needs, so nobody can tell what went wrong.

3.2 What is an environment, and how does it work?

An environment is a project’s own set of packages, at the versions it needs. Instead of one shared library for every project, each project has its own, so projects can’t interfere with each other.

Environments work with two things:

  • A lock file is the recipe: an exact list of packages and versions. It is a small text file, and you keep it with your project.
  • The environment is what gets built from the lock file: the installed packages, in their own folder. Your code only sees the packages in its own environment.

The environment is disposable: you can delete it, and rebuild it from the lock file whenever you like. The lock file is the thing you keep.

Tool uv renv conda pixi
Works with Python R Python, R and other software Python, R and other software
Lock file (keep it) uv.lock renv.lock environment.yml* pixi.lock
Environment (disposable) .venv renv/library Kept by conda, outside your project .pixi
Rebuild it uv sync renv::restore() conda env create -f environment.yml pixi install

uv and renv each work with one language. conda and pixi can install Python, R, and other software that isn’t a package for either (such as GDAL or a C library), which helps if a project mixes languages. pixi is the newer of the two, and works like uv: it keeps the environment in the project folder and writes a lock file for you.

* environment.yml lists the packages, but not always their exact versions, so it isn’t a true lock file. Make it with conda env export > environment.yml, or use conda-lock for a full lock file.

Other tools do the same job, such as Python’s built-in venv with a requirements.txt file. The idea is the same whichever you use: a file that records what the project needs.

3.3 What it looks like in R and Python

You don’t need to run this in the course. It shows what using an environment looks like, so you can try it on a project of your own. There are only two steps to remember: make the environment once, and rebuild it from the lock file whenever you need to. The example folder has a small project in each language to practise on, environment-demo/r/ and environment-demo/python/, with the steps in their READMEs.

With the renv package, in the R console, in your project:

renv::init()                   # make the environment, and the lock file renv.lock
install.packages("ggplot2")    # new packages now go into this project's environment
renv::snapshot()               # record them, at these versions, in renv.lock

On another computer, or after deleting the renv/library folder:

renv::restore()                # rebuild the environment from renv.lock

With uv, in a terminal, in your project folder:

Terminal/Command Prompt
uv init --no-package           # start a project
uv add pandas matplotlib       # make the environment (.venv), install the packages, record them in uv.lock
uv run code/analysis.py        # run your code inside the environment

On another computer, or after deleting the .venv folder:

Terminal/Command Prompt
uv sync                        # rebuild the environment from uv.lock

3.4 Send your project to someone, and it works

This is the payoff. Because the lock file records exactly what the project needs, you can send your project to a colleague, a reviewer, or yourself on a new laptop, and they can rebuild the same environment with one command:

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 share it).
  • Don’t send: the environment itself. It is large, and specific to your computer.

3.5 What environments don’t cover

  • They record packages. Also write down the version of R or Python in your README. (uv can pin the Python version; renv records the R version but doesn’t install it.)
  • The operating system and hardware can still differ.
  • They don’t include your data.

That is good enough for almost every project. Perfect is not the goal.

3.6 What if I use Excel?

There are no packages to install, but the software version can still matter: formulas and functions differ between Excel versions, and add-ins vary. Write the program and its version in your README (for example Excel for Microsoft 365, version 2410), along with any add-ins used. The next person then knows what you used, which is the same idea.

3.7 Optional: trying it yourself

The live session doesn’t need you to run any commands. If you want to try environments yourself:

  • To repeat the demo from the session, copy environment-demo/r/ (R, with renv) or environment-demo/python/ (Python, with uv) from the example folder and follow the steps in its README.md: you set up an environment, delete it, and rebuild it from the lock file.
  • To give a project of your own an environment, in R (with renv) or Python (with uv), work through the capstone exercise.

3.8 Learn more about environments

Try it yourself

The new laptop test

A colleague emails you their project: “It runs fine on my laptop!” You open it on your own laptop, and it says there is no package called ggplot2.

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.

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

Almost all of this can be written down once, in a README. A lock file records the packages for you. Look at tidy-project/README.md: it answers most of these.

TipKey points
  • Use a separate environment for every project.
  • Record it in a lock file and keep that file with your code.
  • An environment is disposable and easy to recreate.
  • Send the lock file, not the environment: your colleague can rebuild it with one command.
  • Write down the version of R or Python, and the operating system, in your README.

4 Your first step

What will you do differently on Monday?

4.1 From messy to shareable

This whole course is one journey:

Messy  ->  Tidy  ->  Documented  ->  Reported  ->  Recorded  ->  Shareable
  • Tidy: raw data kept apart and never edited.
  • Documented: a README and a data dictionary.
  • Reported: one document, made from the data and code.
  • Recorded: the software and versions written down.
  • Shareable: a project a colleague can run on a new computer.

Each step is a habit, and you can start with any of them.

4.2 Your checklist

Tick what your own project already does. There is a one-page version to print or edit in the example folder (checklist.pdf and checklist.docx).

Structure ☐ My raw data is never edited
☐ Raw data, cleaned data, code and results are kept in separate places
☐ My files have clear names
☐ I could re-make my results from the raw data
Documentation ☐ There is a README
☐ My columns are explained in a data dictionary
☐ My report is made from the data and code
Environments ☐ I have written down which software and versions I used
☐ My packages are recorded in a file
☐ A colleague could run my project on a new computer
Sharing ☐ My data is in an open format such as CSV
☐ I know where I would share it, and under which licence
☐ Someone else could find, understand and reuse it

4.3 Quick wins

Some steps give a lot of benefit for very little effort:

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

Try it yourself

Your checklist

  1. Tick the checklist for a project of your own (or for messy-project/ if you don’t have one).
  2. Circle one thing to start with this week.
  3. Write it down, or tell someone, so you do it.

There is no single right answer, but a good first step is small and quick. If you can’t decide, start with the first thing in the quick wins table that you haven’t done yet. A README is a very good first step: it takes 15 minutes, and it helps everyone, including future you.

4.4 Where next?

  • The Turing Way: a community guide to reproducible research, covering all of these topics in depth.
  • Bristol Training courses: including Intermediate R, Intermediate Python and Best Practices in Software Engineering.
  • Version control with git lets you go back to a version that worked, develop new features in branches, and collaborate. We cover it in a separate git and GitHub course.
  • Functions and testing make analysis code easier to read and trust. See the courses above.
  • Sharing your data: the next section covers Q-FAIR in full.
  • Capstone exercise: an optional exercise that puts it all together, where you build a project from scratch, with an environment and a report with code, in R or Python.

Getting the balance right is hard: do what you can. You learn by doing, so try to put one or two of these ideas into your next project.

TipKey points
  • Each habit is small, and you can start with any of them.
  • A project that is tidy, documented, reported and recorded is already most of the way to reproducible.
  • Pick one thing, and do it this week.

5 Optional: Sharing your data (Q-FAIR)

How do I know my data is good enough to share, and how do I share it?

This section is optional in the live course, but it is written in full so you can work through it on your own.

5.1 Q-FAIR data principles

The FAIR principles are a well-known checklist for sharing data. Q-FAIR adds Quality at the start:

Letter Principle What it means in practice Where we met it
Q Data Quality Data is accurate, complete and documented. You know where it came from and what was done to it. Raw data is never overwritten; the pipeline records every change.
F Findable People, and computers, can find it. It has a clear name and description. Clear folder layout and a README.
A Accessible It is clear how to get the data, and under what conditions. README setup and access notes.
I Interoperable It uses open, standard formats that other tools can read. CSV, not a locked format.
R Reusable Others can understand and re-use it, with a clear licence. A README and a data dictionary.

5.2 Why it matters

  • Funders and journals increasingly expect data to be shared.
  • Others can build on your work, and check it.
  • Future you can find and understand your own data.
  • Your work gets cited.

5.3 A worked example

Here is how the two example projects score against each letter:

Question tidy-project/ messy-project/
Q Can you trust it, and do you know what was done to it? ✔ The raw data is untouched and the code records every change ✘ Three cleaned versions, and some values were fixed by hand
F Can people find it? ✔ Clear names and a README ✘ data_FINAL_USE_THIS.csv
A Is it clear how to get it? ✔ The README says where everything is ✘ “Ask Sam”
I Is it in an open format? ✔ CSV ✘ Results in .xlsx
R Can others understand and reuse it? ✔ A data dictionary (it still needs a licence) ✘ Columns not explained, no licence

5.4 Four things to do

1. Use open file formats. Share data as CSV (comma-separated values), which is plain text that every tool can read, rather than a format that needs one program. In Excel, use File > Save As and choose CSV UTF-8. A CSV holds one sheet only, and keeps values, not formulas.

2. Describe your data. Write a data dictionary, with one row per column, as in the Documentation section, and keep it next to the data.

3. Add a licence. Without one, others don’t know whether they can reuse your work. Common choices are CC BY 4.0 for data and text, and MIT for code. The Creative Commons chooser and choosealicense.com can help. Your funder or institution may have requirements, so check first.

4. Deposit it. Put the data in a repository that gives it a permanent home and a DOI (a persistent identifier you can cite), such as Zenodo, your institution’s data repository (at Bristol this is data.bris), or one specific to your field.

Sensitive data. Some data can’t be shared openly, for example because it contains personal information. You can usually still share the metadata (the README and data dictionary) and explain how others can apply for access. Check with your research data team or ethics committee before depositing anything involving people.

Try it yourself

Q-FAIR detective

For each of these three datasets, mark every letter of Q-FAIR with a ✔ or an ✘.

  • 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.
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 it is hard to find (F), you need permission to get it (A), and it has no licence (R).

TipKey points
  • Q-FAIR: data Quality, Findable, Accessible, Interoperable, Reusable.
  • Share data in open formats such as CSV, with a data dictionary and a licence.
  • Deposit it in a repository that gives it a DOI.
  • If data can’t be shared, share the metadata and explain how to ask for access.