Datasets

The example data used across this site: a quality-control lab working with ibuprofen 400 mg tablets. View each dataset, read what it contains, and download it for your own work.

All examples on this site share one running story: a QC lab receives a batch of ibuprofen 400 mg tablets and works through four classic experiments — weigh the tablets, dissolve them, titrate the extracted drug, and build a UV calibration curve.

The files follow a simple design rule: one defect per file. Four datasets are clean, and each “messy” variant reuses one of them with exactly one realistic problem, so you learn the data once and then only have to learn the defect.

Every interactive code cell on this site can load these files directly with read_csv("data/...") — no setup needed. To use a dataset in RStudio, click its download button and place the file in a data/ folder inside your R project — see Setting Up an R Project for the recommended folder layout.

Clean datasets

tablet_weights.csv — tablet weights off the production line

24 individual tablets weighed straight off the line, 8 from each of three batches (A, B, C), with a target weight of about 500 mg. This is the go-to dataset for inspecting, filtering, grouping, and summarising.

Column Type Meaning
tablet_id numeric Tablet number (1–24)
batch character Production batch: A, B, or C
weight_mg numeric Measured tablet weight in milligrams

Download tablet_weights.csv ⬇

dissolution.csv — drug release over time

Six tablets placed in dissolution fluid, with the percentage of drug released measured at seven time points per tablet (42 rows). The release climbs toward 100% following first-order kinetics — ideal for plotting curves with ggplot().

Column Type Meaning
tablet_id numeric Tablet number (1–6)
time_min numeric Sampling time in minutes
pct_dissolved numeric Percent of the drug released so far

Download dissolution.csv ⬇

titration.csv — acid–base titration curves

Acid–base titration of extracted ibuprofen (a weak acid, pKa 4.91) with 0.100 M NaOH. Three replicate samples (A, B, C) are titrated in 2 mL steps, 26 readings each, with equivalence points at 24.5, 25.0, and 25.5 mL.

Column Type Meaning
sample_id character Replicate sample: A, B, or C
volume_ml numeric Volume of NaOH added, in mL
pH numeric Measured pH

Download titration.csv ⬇

calibration.csv — UV calibration curve

An ibuprofen UV calibration series following the Beer–Lambert law: absorbance rises linearly with concentration across 11 standards (R² ≈ 0.9999). This is the dataset for lm(), coef(), and predict().

Column Type Meaning
conc_ug_ml numeric Standard concentration in µg/mL
absorbance numeric Measured UV absorbance

Download calibration.csv ⬇

Messy variants

Each file below is one of the clean datasets with a single realistic problem built in. Run the cell to see the problem for yourself — the page for the matching function shows how to fix it.

dissolution_dk.csv — Danish CSV export (semicolons and comma decimals)

The dissolution data as exported by software with Danish regional settings: semicolons separate the columns and commas mark the decimals. A plain read_csv() crams everything into one column — this file teaches read_csv2().

Download dissolution_dk.csv ⬇

titration_missing.csv — mixed missing-value codes

The titration data for sample B, but a few pH readings were recorded as N/A, -, or simply left blank. Because of the text codes, read_csv() imports the whole pH column as text instead of numbers — this file teaches the na = argument of read_csv().

Download titration_missing.csv ⬇

weights_units.csv — numbers stored as text

The tablet weights, but someone typed the unit into every cell ("506.3 mg"). The weight_mg column arrives as text, so you can’t calculate with it — this file teaches parse_number() and type conversion.

Download weights_units.csv ⬇

weights_duplicates.csv — rows logged twice

The tablet weights, but tablets 5 and 18 were accidentally logged twice, so the file has 26 rows for 24 tablets. Counting the IDs reveals the duplicates — this file teaches distinct().

Download weights_duplicates.csv ⬇

batches_messy.csv — inconsistent batch labels

The tablet weights, but the batch column was typed by hand: the same batch appears as A, a, Batch A, and " A" (with a stray space). Grouping or counting by batch splits one batch into several — this file teaches str_trim() and str_to_upper().

Download batches_messy.csv ⬇

weights_export.csv — instrument export with metadata block

The tablet weights as a raw balance export: four metadata lines sit above the header, and missing readings use mixed codes (NA, N/A, -, blank). This is the one deliberate two-defect file, so you can combine skip = and na = in a single read_csv() call.

Download weights_export.csv ⬇

Excel workbooks

lab_results.xlsx — all four experiments in one workbook

One workbook with five sheets: Weights, Dissolution, Titration, and Calibration (the four clean datasets), plus Weights (missing) — the weights with four readings gone, written with mixed NA codes (N/A, -, ND, blank). It teaches read_excel() with the sheet = and na = arguments.

Download lab_results.xlsx ⬇

lab_results_titled.xlsx — title block above the header

The weights data with a three-row title block above the column names, so the real header sits on row 4. Reading it naively turns the title into column names — this file teaches read_excel(skip = 3).

Download lab_results_titled.xlsx ⬇