calculate_age_from_dob {IPDFileCheck}R Documentation

Function to calculate age from date of birth

Description

Function to calculate age from date of birth

Usage

calculate_age_from_dob(
  data,
  columnname,
  enddatecol = NULL,
  dateformat = "dmy",
  nrcode = NA
)

Arguments

data

a data frame

columnname

name of column corresponding to date of birth

enddatecol

column contaiining when to calculate the age to, default value is null, this means the age is calculated to the current date

dateformat

format of date e.g. dmy default is dmy

nrcode

non response code corresponding to date of birth

Value

data if success error if failure

Examples

library(IPDFileCheck)
this.df <- data.frame(c("1987-05-28", "1987-06-18"), c(1, 2),
stringsAsFactors = FALSE)
colnames(this.df) <- c("dob", "num")
calculate_age_from_dob(this.df, "dob", NULL, "ymd")

[Package IPDFileCheck version 0.8.1 Index]