powered by
Function to calculate age from year of birth
calculate_age_from_year(data, columnname, endyearcol = NULL, nrcode = NA)
data, if success error if failure
a data frame
name of column corresponding to year of birth
name of column where the year is entered to calculate the age upto, by default its the current year
non response code corresponding to date of birth
this.data.frame <- data.frame(c(1951, 1980), c("John", "Dora")) colnames(this.data.frame) <- c("yob", "name") calculate_age_from_year(this.data.frame, "yob", NULL, NA)
Run the code above in your browser using DataLab