| Title: | Work with Romanian Personal Numeric Codes PNC / CNP |
|---|---|
| Description: | A set of tools for working with Romanian personal numeric codes. The core is a validation function which applies several verification criteria to assess the validity of numeric codes. This is accompanied by functionality for extracting the different components of a personal numeric code. A personal numeric code is issued to all Romanian residents either at birth or when they obtain a residence permit. |
| Authors: | Dragoș Moldovan-Grünfeld [aut, cre, cph] |
| Maintainer: | Dragoș Moldovan-Grünfeld <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9001 |
| Built: | 2026-05-12 07:14:17 UTC |
| Source: | https://github.com/dragosmg/rocnp |
cnp objectcnp() is used to build a cnp vector
is_cnp is used to check whether a vector is of class cnp
cnp(x = character()) is_cnp(x)cnp(x = character()) is_cnp(x)
x |
(character) a character (or values that can be cast to character) vector of personal numeric codes (CNPs). |
cnp(): a vector of class cnp.
is_cnp(): a logical vector.
a <- cnp(c("1940616346114", "7041218318525")) is_cnp(a) is_cnp(1L:3L)a <- cnp(c("1940616346114", "7041218318525")) is_cnp(a) is_cnp(1L:3L)
A lookup table mapping the county code to the county name.
county_lookupcounty_lookup
county_lookupA data frame with 48 rows and 2 columns:
county code
county name
https://ro.wikipedia.org/wiki/Cod_numeric_personal_(România)#JJ
A lookup table containing the number of days in a month.
days_in_monthdays_in_month
days_in_monthA data frame with 12 rows and 3 columns:
month as padded character - "01" to "12"
number of days in a non-leap year
number of days in a leap year
The extract_() family of functions provides tools to extract the different
pieces of information encoded in the CNP. These functions return a character
vector:
extract_sex() extracts the sex ("M" or "F") based on the S
component of the CNP.
extract_birth_year() extracts the year of birth, inferred from the S
(which also encodes the century of birth, alongside the sex ) and AA
(encoding the final 2 digits of the birth year) components of the CNP.
extract_birth_month() extracts the month of birth based on the "LL"
component.
extract_county() gets the county of issue (based on the JJ component).
extract_status() extracts the residence status (based on the S
component)
This function returns a date vector:
extract_dob() gets the date of birth (based on the S, AA, LL, and
ZZ components).
extract_sex(x) extract_birth_year(x) extract_birth_month(x) extract_dob(x) extract_county(x) extract_status(x)extract_sex(x) extract_birth_year(x) extract_birth_month(x) extract_dob(x) extract_county(x) extract_status(x)
x |
a |
extract_sex(): a character vector containing the parsed sex: M or F.
extract_birth_year(): a character vector containing the birth year.
extract_birth_month(): a character vector containing the birth month.
extract_county(): a character vector containing the county of issue.
extract_status(): a character vector containing the residence status
("native" or "resident").
extract_dob(): a vector of containing the date of birth.
# Extract sex extract_sex(cnp(c("5201206346491", "1940616346114", "7041218318525", NA))) # Extract birth year extract_birth_year( cnp(c("5201206346491", "1940616346114", "7041218318525", NA)) ) # Extract birth month extract_birth_month(cnp(c(5201206346491, 1940616346114, 7041218318525, NA))) # Extract date of birth extract_dob(cnp(c("5201206346491", "1940616346114", "7041218318525", NA))) # Extract county extract_county(cnp(c("5201206346491", "1940616346114", "7041218318525", NA))) # Extract residence status extract_status(cnp(c("5201206346491", "1940616346114", "7041218318525", NA)))# Extract sex extract_sex(cnp(c("5201206346491", "1940616346114", "7041218318525", NA))) # Extract birth year extract_birth_year( cnp(c("5201206346491", "1940616346114", "7041218318525", NA)) ) # Extract birth month extract_birth_month(cnp(c(5201206346491, 1940616346114, 7041218318525, NA))) # Extract date of birth extract_dob(cnp(c("5201206346491", "1940616346114", "7041218318525", NA))) # Extract county extract_county(cnp(c("5201206346491", "1940616346114", "7041218318525", NA))) # Extract residence status extract_status(cnp(c("5201206346491", "1940616346114", "7041218318525", NA)))