Data quality on the ISO/IEC 25012 model, without a data dictionary
Most tools that check data quality ask you for something before they check anything. dataquieR and DQAstats want a metadata repository. pointblank, validate and dataverifyr want you to write the rules. That is the right design when the data is yours and documented. It is the wrong one for the moment that comes first: a file has arrived, nobody has described it, and you want to know whether it is fit to use.
datagrade is an R package I wrote for that moment. It scores a table against the ISO/IEC 25012 data quality model and runs on any data frame with no setup. This post shows what it does with nothing, what it does once you tell it a little, and what it does when the same data set arrives twice.
The model in one paragraph
ISO/IEC 25012 describes data quality through characteristics. Five of them are inherent, meaning they belong to the data itself rather than to the system holding it: accuracy, completeness, consistency, credibility and currentness. Its companion standard, ISO/IEC 25024, measures them through quality properties, each a ratio A / B of counted data items. A counts the items that satisfy the property. B counts the items for which the property is defined at all.
That second number is the whole story. For six of the fifteen properties, B can be counted from the table: every cell, every record, every text value. For the other nine it cannot. “Accuracy range” needs to know what the valid range is; “referential integrity” needs to know which table a key points at. No data set contains its own expectations, so those nine need you to declare them.
Nothing declared
Here is a small made-up patient table with the kinds of fault real extracts have: placeholder text where a ward should be, an age of 212, missing blood pressures, and three admission dates typed in a different format from the rest.
install.packages("datagrade")
library(datagrade)
set.seed(42)
n <- 400
patients <- data.frame(
patient_id = sprintf("P-%04d", 1:n),
ward = sample(c("cardio", "renal", "oncology"), n, replace = TRUE),
age = round(rnorm(n, 62, 14)),
sbp = round(rnorm(n, 132, 18)),
admitted = format(as.Date("2026-01-01") + sample(0:300, n, replace = TRUE))
)
patients$ward[c(3, 17, 90, 211)] <- c("N/A", "unknown", "-", "N/A")
patients$age[c(8, 44)] <- c(-1, 212)
patients$sbp[sample(n, 30)] <- NA
patients$admitted[5:7] <- c("03/02/2026", "2026/02/14", "14 Feb 2026")
report <- dg_assess(patients)
── ISO/IEC 25012 characteristics ──
• accuracy: not applicable (0/3 measures)
• completeness: 0.968 (96.8%) - good (3/4 measures)
• consistency: 0.998 (99.8%) - good (2/4 measures)
• credibility: not applicable (0/2 measures)
• currentness: 1.000 (100%) - good (1/2 measures)
Overall: 0.989 (98.9%) - good
── Findings ──
• Missing values: 30 across 1 column
• Identifier column (excluded from statistics): patient_id
• Dates in another format: 3 in admitted (e.g. 03/02/2026, 2026/02/14, 14
Feb 2026), counted against format consistency
The six measures that need nothing have run. report$measures shows each one with its counts, so every score can be checked by hand:
code characteristic value a b
COMP_REG completeness 0.925 370 400
COMP_VAL_ESP completeness 0.985 1970 2000
FAL_COMP_FICH completeness 0.995 796 800
RIES_INCO consistency 1.000 2 2
CONS_FORM consistency 0.995 1194 1200
CONV_ACT currentness 1.000 397 397
FAL_COMP_FICH, false completeness, found the four wards that are filled in but say nothing (“N/A”, “unknown”, “-”). A plain missing-value count reports those cells as complete. CONS_FORM found the three dates in the wrong format: each column is measured against its own dominant shape, so no format had to be declared.
Accuracy says not applicable, not zero. That difference matters. A zero would be a claim that the data is wrong. NA says the standard’s denominator could not be counted, because nothing has said what a correct age is. The overall score is taken over the characteristics that could be measured, and the report says how many that was.
A little declared
Three lines of expectation switch accuracy on:
spec <- dg_spec(
patterns = list(patient_id = "^P-[0-9]{4}$"),
domains = list(ward = c("cardio", "renal", "oncology")),
ranges = list(age = c(0, 110), sbp = c(60, 250))
)
report <- dg_assess(patients, spec = spec)
report$measures[1:3, c("code", "value", "a", "b")]
code value a b
EXAC_SINT 0.9950000 796 800
EXAC_SEMAN NA NA NA
RAN_EXAC 0.9974026 768 770
Syntactic accuracy is 796 of 800: the four placeholder wards are outside the permitted domain. Range accuracy is 768 of 770: the ages of −1 and 212. Semantic accuracy is still NA, because it needs a reference table to compare against, and none was given. Every argument to dg_spec() is optional. Each one you add switches on the measures that depend on it.
The same data, twice
Data you use more than once arrives more than once: a monthly extract, a nightly export, a registry refresh. The useful question then is not “how good is this file” but “what changed since the last one”. Version 0.3.0 adds dg_compare() for that. It scores both versions under the same specification and settings, so a change in a score is a change in the data and not in the yardstick.
Suppose December’s extract loses the age column upstream, a quarter of blood pressures go missing, and someone’s export starts writing wards as "Cardio ":
december <- patients
december$sbp[sample(n, 80)] <- NA
december$ward[sample(n, 25)] <- "Cardio "
december$age <- NULL
dg_compare(patients, december, spec = spec)
── ISO/IEC 25012 characteristics ──
• accuracy: 0.996 -> 0.982 (declined)
• completeness: 0.968 -> 0.896 (declined)
• consistency: 0.998 -> 0.996 (unchanged)
• credibility: n/a -> n/a (not applicable)
• currentness: 1.000 -> 1.000 (unchanged)
Overall: 0.991 -> 0.968 (declined)
── Measures that changed ──
• `EXAC_SINT` Syntactic accuracy: 0.995 -> 0.965 (declined)
• `COMP_REG` Record completeness: 0.925 -> 0.752 (declined)
• `COMP_VAL_ESP` Data value completeness: 0.985 -> 0.938 (declined)
• `RIES_INCO` Risk of inconsistency: 1.000 -> n/a (lost)
── What changed in the data ──
• Columns removed: age
• More missing values in: sbp (7.5% -> 24.8%)
Each fault shows up once, in the measure it belongs to. The capitalised ward fails the domain check. The missing pressures lower both completeness measures. Losing a column is reported as a change to the structure, and the multicollinearity measure, which needed two numeric columns, is reported as lost rather than as a drop to zero.
Changes smaller than a tolerance (one percentage point by default) are reported as unchanged, so the output is about what moved, not about noise.
On real data
I tested the release on public data: two days of NYC 311 service requests from October 2026 and two from November (about 23,000 rows and 44 columns each), 50,000 Chicago crime records, and the flights, weather and penguin data sets that R users know. The largest of these, 337,000 flights, took about three seconds.
The 311 data found two bugs, both fixed in 0.3.0. A date column in which many cells were blank, the closing date of cases still open, was not recognised as dates at all. And a date written in a minority format was counted as missing when it was present. Synthetic tests had not caught either.
Comparing October with November then gives one finding worth reading:
── What changed in the data ──
• More missing values in: closed_date (6.2% -> 10.5%)
That is not a fall in quality. The November file was downloaded closer to the days it covers, so more of its cases were still open. A comparison tells you what changed; it takes someone who knows the data to say whether the change is a fault. That is why the output lists the change rather than an alarm.
What it is not
The measures implement properties named in ISO/IEC 25024, but they are not reproductions of the standard’s own measurement functions, and the weights, thresholds and format heuristic are my design decisions. Treat the scores as screening, not as evidence of conformance. The methodology vignette states every formula, and the deviations vignette records where the package departs from the MSc dissertation it came from, including the errors in the original code that it corrects.
Try it
install.packages("datagrade")
dg_compare() arrives with 0.3.0. Until CRAN publishes it, the development version has it:
remotes::install_github("ohalukdemirhan/datagrade")
The code is on GitHub. If you run it on your own data and something reads wrong, an issue is the most useful thing you can send me. Both bugs above came from data I had not made myself, and yours will find the next ones.