Imported columns often arrive as text, so a type scan should find values that do not match the intended shape.

Program

Play the script to change how many bad numeric values are tolerated.

type_scan.R
score_text <- c("91", "84", "oops", "76")
allowed_bad <- 
is_number <- grepl("^[0-9]+$", score_text)
bad <- sum(!is_number)
status <- if (bad <= allowed_bad) "ok" else "fix"
label <- paste(status, bad, sep = ":")
cat(label, "\n", sep = "")
score_text <- c("91", "84", "oops", "76")
allowed_bad <- 
is_number <- grepl("^[0-9]+$", score_text)
bad <- sum(!is_number)
status <- if (bad <= allowed_bad) "ok" else "fix"
label <- paste(status, bad, sep = ":")
cat(label, "\n", sep = "")
score_text <- c("91", "84", "oops", "76")
allowed_bad <- 
is_number <- grepl("^[0-9]+$", score_text)
bad <- sum(!is_number)
status <- if (bad <= allowed_bad) "ok" else "fix"
label <- paste(status, bad, sep = ":")
cat(label, "\n", sep = "")
text input Imported values can start as strings even when the column should be numeric.
shape test `grepl("^[0-9]+$", score_text)` marks values that look numeric.
tolerance `allowed_bad` decides whether the import can continue or needs repair.