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)