Title: | Functions for Working with Danish CPR Numbers |
---|---|
Description: | Calculate date of birth, age, and gender, and generate anonymous sequence numbers from CPR numbers. <https://en.wikipedia.org/wiki/Personal_identification_number_(Denmark)>. |
Authors: | Jacob Anhoej |
Maintainer: | Jacob Anhøj <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0 |
Built: | 2025-01-07 03:28:19 UTC |
Source: | https://github.com/anhoej/cprr |
Calculate ages from CPR numbers.
age(cpr, date = Sys.Date(), unit = "year")
age(cpr, date = Sys.Date(), unit = "year")
cpr |
Character vector of CPR numbers with or without hyphens. |
date |
Character or date vector of dates used in computation of ages. Dates provided as characters must follow the ISO standard, 'yyyy-mm-dd'. |
unit |
Character indicating the unit representing ages. Possible values are: 'year', 'month', 'week', 'day'. |
Numeric vector of ages. By default ages are computed in years. Note that year and month units are calculated by approximaion, 1 year = 365.25 days, 1 month = 30.44 days.
age(c('1508631111', '1310762222'))
age(c('1508631111', '1310762222'))
Calculate dates of birth from CPR numbers.
dob(cpr)
dob(cpr)
cpr |
Character vector of CPR numbers with or without hyphens. |
Vector of dates of birth.
dob(c('1508631111', '1310762222'))
dob(c('1508631111', '1310762222'))
Calculate genders from CPR numbers.
gender(cpr)
gender(cpr)
cpr |
Character vector of CPR numbers with or without hyphens. |
Integer vector of genders: 0 = female, 1 = male.
gender(c('1508631111', '1310762222'))
gender(c('1508631111', '1310762222'))
Check if CPR numbers conform to modulo 11 check. Note, modulo 11 check was deprecated in 2007.
mod11(cpr)
mod11(cpr)
cpr |
Character vector of CPR numbers with or without hyphens. |
Logical vector of check results, NA if CPR number includes characters (temporary CPR number).
mod11(c('1508631111', '1310762222', '2110625629'))
mod11(c('1508631111', '1310762222', '2110625629'))
Make "anonymous" random numbers from CPR numbers.
scramble(cpr)
scramble(cpr)
cpr |
Character vector of CPR numbers with or without hyphens. |
Integer vector. Each integer represents one unique CPR number.
scramble(c('1508631111', '1310762222', '1508631111'))
scramble(c('1508631111', '1310762222', '1508631111'))
A dataset containing the list of CPR numbers used for testing calculation of date of birth and gender.
test_cpr
test_cpr
A data frame with 30 rows and 3 columns.
CPR number
Date of birth
Gender, 0 = female, 1 = male
...
http://medcom.dk/opslag/koder-tabeller-ydere/tabeller/nationale-test-cpr-numre