get_sex {rocnp}R Documentation

Extract the Sex from the Personal Numeric Code

Description

This function extracts the sex based on the sex component S of the CNP. It is worth noting that, at the moment of the implementation, Romanian authorities define sex as binary. In the event of a sex change a new CNP could be issued. The function returns an error if there is at least one invalid CNP in the input vector, forcing you to confront the issue early. The easiest way to get around this is to use check_cnp_is_valid().

Usage

get_sex(cnp)

Arguments

cnp

a 13-digit number (or a vector of 13-digit numbers) representing the Personal Numeric Code - CNP

Value

a character vector of the recorded sex: M, F (if the CNP is valid) or NA_character if the CNP is missing

Examples

get_sex(1940616346114)
get_sex(7041218318525)
get_sex(6201206018078)
get_sex(5201206346491)
get_sex(c(5201206346491, 1940616346114, 7041218318525, 6201206018078))
get_sex(c(5201206346491, 1940616346114, 7041218318525, NA))

[Package rocnp version 0.1.0 Index]