Learn R Programming

sweidnumbr (version 1.5.0)

pin_age: Calculate age of pin for a given date

Description

Calculate the age in full years for a given date.

Usage

pin_age(pin, date = Sys.Date(), timespan = "years", verbose = TRUE)

Value

Age as an integer vector.

Arguments

pin

A vector of class pin. See as.pin.

date

Date at which age is calculated. If a vector is provided it must be of the same length as the pin argument.

timespan

Timespan to use to calculate age. The actual timespans are:

  • years (Default)

  • months

  • weeks

  • days

verbose

Should messages be printed? Default is TRUE.

References

Examples

Run this code
# Example with someone born today
today_pin <- 
  paste(paste(unlist(strsplit(as.character(Sys.Date()),split = "-")), collapse = ""),
        "0000",sep="")
pin_age(today_pin)

# Examples taken from SKV 704 (see references)
ex_pin <- c("196408233234", "186408833224")
pin_age(ex_pin, date = "2012-01-01")

Run the code above in your browser using DataLab