A checkFunction that checks if v consists exclusively of valid Danish civil registration (CPR) numbers, ignoring missing values. This function is intended for use as a precheck in makeDataReport, ensuring that CPR numbers are not included in a dataMaid output document.

isCPR(v, ...)

Arguments

v

A variable (vector) to check. This variable is allowed to have any class.

...

Not in use.

Value

A checkResult with three entires: $problem (a logical indicating whether the variable consists of CPR numbers), $message (if a problem was found, the following message: "Warning: The variable seems to consist of Danish civil registration (CPR) numbers.", otherwise "") and $problemValues (always NULL).

See also

Examples

CPRs <- sapply(c("01011988", "02011987", "04052006", "01021990", "01021991", "01021993", "01021994", "01021995", "01021996", "01021997", "01021970", "01021971", "01021972", "01021973", "01021974"), dataMaid:::makeCPR) nonCPRs <- c(1:10) mixedCPRs <- c(CPRs, nonCPRs) #identify problem isCPR(CPRs)
#> Warning: The variable seems to consist of Danish civil regristration (CPR) numbers.
#no problem as there are no CPRs isCPR(nonCPRs)
#> No problems found.
#no problem because not ALL values are CPRs isCPR(mixedCPRs)
#> No problems found.