isCPR: Check if a variable consists of Danish CPR numbers

Description Usage Arguments Value See Also Examples

View source: R/isCPR.R

Description

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 dataReporter output document.

Usage

1
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

check, allCheckFunctions, checkFunction, checkResult

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
CPRs <- c("010188-3639", "020187-1476", "040506-8664", "010290-3684", "010291-1180",
          "010293-1599", "010294-1268", "010295-1360", "010296-3970", "010297-2007",
          "010270-2905", "010271-0134", "010272-1403", "010273-3088", "010274-1633")
nonCPRs <- c(1:10)
mixedCPRs <- c(CPRs, nonCPRs)

#identify problem
isCPR(CPRs)

#no problem as there are no CPRs
isCPR(nonCPRs)

#no problem because not ALL values are CPRs
isCPR(mixedCPRs)

dataReporter documentation built on Nov. 11, 2021, 9:06 a.m.