powered by
Function to calculate age from date of birth
calculate_age_from_dob( data, columnname, enddatecol = NULL, dateformat = "dmy", nrcode = NA )
data if success error if failure
a data frame
name of column corresponding to date of birth
column contaiining when to calculate the age to, default value is null, this means the age is calculated to the current date
format of date e.g. dmy default is dmy
non response code corresponding to date of birth
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")
Run the code above in your browser using DataLab