Skip to contents

Extract embedded information from Finnish personal identity codes (hetu).

Usage

hetu(pin, extract = NULL, allow.temp = FALSE, diagnostic = FALSE)

Arguments

pin

Finnish personal identity code(s) as a character vector

extract

Extract only selected part of the information. Valid values are "hetu", "sex", "p.num", "ctrl.char", "date", "day", "month", "year", "century", "is.temp". If NULL (default), returns all information.

allow.temp

Allow artificial or temporary PINs (personal numbers 900-999). If FALSE (default), only PINs intended for official use (personal numbers 002-899) are allowed.

diagnostic

Print additional information about possible problems in PINs. The checks are "valid.p.num", "valid.ctrl.char", "correct.ctrl.char", "valid.date", "valid.day", "valid.month", "valid.length", "valid.century". Default is FALSE which returns no diagnostic information.

Value

Finnish personal identity code data.frame, or if extract parameter is set, the requested part of the information as a vector. Returns an error or NA if the given character vector is not a valid Finnish personal identity code.

hetu

Finnish personal identity code as a character vector. A correct pin should be in the form DDMMYYCZZZQ, where DDMMYY stands for date, C for century sign, ZZZ for personal number and Q for control character.

sex

sex of the person as a character vector ("Male" or "Female").

p.num

Personal number part of the identity code.

ctrl.char

Control character for the personal identity code.

date

Birthdate.

day

Day of the birthdate.

month

Month of the birthdate.

year

Year of the birthdate.

century

Century character of the birthdate: + (1800), - (1900) or A (2000).

valid.pin

Does the personal identity code pass all validity checks: (TRUE or FALSE)

See also

pin_ctrl For validating Finnish personal identity codes.

Author

Pyry Kantanen, Jussi Paananen

Examples

hetu("111111-111C")
#>          hetu  sex p.num ctrl.char       date day month year century valid.pin
#> 1 111111-111C Male   111         C 1911-11-11  11    11 1911       -      TRUE
hetu("111111-111C")$date
#> [1] "1911-11-11"
hetu("111111-111C")$sex
#> [1] "Male"
# Same as previous, but using extract argument
hetu("111111-111C", extract="sex")
#> [1] "Male"
# Process a vector of hetu's
hetu(c("010101-0101", "111111-111C"))
#>          hetu    sex p.num ctrl.char       date day month year century
#> 1 010101-0101 Female   010         1 1901-01-01   1     1 1901       -
#> 2 111111-111C   Male   111         C 1911-11-11  11    11 1911       -
#>   valid.pin
#> 1      TRUE
#> 2      TRUE
# Process a vector of hetu's and extract sex information from each
hetu(c("010101-0101", "111111-111C"), extract="sex")
#> [1] "Female" "Male"