Session 2 Lecture: The Architecture of Tidy Tables

Master Codd's relational design rules adapted for modern clinical bioinformatics: separating variables into columns, observations into rows, and structural cell units into singular values.

1. The Three Structural Rules of Tidy Data

In computational clinical research, predictable tabular layout isn't an aesthetic preference—it is a functional necessity. Tidy data provides a standardized shape for tabular datasets. Developed by Hadley Wickham, the framework adapts classic relational database norms into three non-negotiable architectural rules: 1. Each variable forms a column. 2. Each observation forms a row. 3. Each cell contains a single, atomic value.

2. Variables vs. Observations in Clinical Assays

The hardest part of tidying data is recognizing what actually constitutes a 'variable' versus an 'observation'. A variable is an underlying metric or attribute you can measure across all subjects (e.g., heart rate, blood glucose, drug concentration). An observation captures all measurements collected for a single, unique empirical unit (such as a specific patient visit, a timepoint, or a tissue sample ID) at a specific point in space and time.

The Tidy Shape Rule of Thumb

If a column header in your laboratory sheet is a value (like 'Day_0', 'Day_14') rather than a clean attribute description (like 'timepoint'), your table is wider than it is tidy. Values belong inside the rows, not acting as column infrastructure.

3. The Atomic Value Rule

Every cell must contain an atomic value—meaning it holds exactly one data element. Combining metrics into a single string (e.g., writing '120/80' for blood pressure or combining gender and age as 'M-45') shatters algorithmic parsing engines. R vectors cannot process complex composite sub-elements without intensive, error-prone string parsing routines.

# Example of a tidy data layout initialized as a tibble:
library(tibble)

tidy_patients <- tibble(
patient_id = c("PT01", "PT02", "PT03"),
systolic_bp = c(120, 142, 118),
diastolic_bp = c(80, 92, 75)
)

print(tidy_patients)

Practical Assignment

Objective: Architect a structurally compliant tidy data frame object from raw clinical vector primitives.

Instructions:
1. Open your local RStudio environment.
2. Create a clean tibble or data frame that stores observations for 3 distinct research subjects.
3. Isolate the following untidy clinical log entries: Patient 1 has blood pressure 130/85. Patient 2 has blood pressure 115/75. Patient 3 has blood pressure 140/90.
4. Design your data frame architecture to follow tidy guidelines by splitting the blood pressure entry into two distinct, numeric variable columns named 'bp_systolic' and 'bp_diastolic'.
5. Print your completed data structure to verify that each row contains a single clinical observation and each cell holds a singular, isolated scalar value.

Proof of Work: Your structure is architected correctly if printing your object reveals a clean rectangular data grid featuring 3 rows and exactly 3 columns (patient_id, bp_systolic, bp_diastolic) containing purely uniform numeric data types under the blood pressure variables.

Lesson Metadata

Duration: 45 mins
Module Scope: Bioinformatics Bootcamp 2026: Computational Thinking for Biomedical Research