arguments <- commandArgs(trailingOnly = TRUE)
path <- if (length(arguments)) arguments[[1L]] else "schools.csv"
untyped <- read.csv(path, check.names = FALSE)
typed <- read.csv(
  path, check.names = FALSE,
  colClasses = c("CDS Code" = "character")
)
keys <- typed[["CDS Code"]]
inferred <- format(untyped[["CDS Code"]], scientific = FALSE, trim = TRUE)
stopifnot(
  is.character(keys), is.numeric(untyped[["CDS Code"]]),
  nrow(typed) == nrow(untyped),
  all(grepl("^[0-9]{14}$", keys)), !anyDuplicated(keys)
)
missing <- !inferred %in% keys
cat(R.version.string, "\n")
print(data.frame(
  Rows = length(keys),
  Unique = length(unique(keys)),
  Different = sum(inferred != keys),
  Unmatched = sum(missing)
), row.names = FALSE)
print(data.frame(
  Original = head(keys[missing], n = 1),
  Inferred = head(inferred[missing], n = 1)
), row.names = FALSE)
