Learn R Programming

IPDFileCheck (version 0.8.1)

calculate_age_from_year: Function to calculate age from year of birth

Description

Function to calculate age from year of birth

Usage

calculate_age_from_year(data, columnname, endyearcol = NULL, nrcode = NA)

Value

data, if success error if failure

Arguments

data

a data frame

columnname

name of column corresponding to year of birth

endyearcol

name of column where the year is entered to calculate the age upto, by default its the current year

nrcode

non response code corresponding to date of birth

Examples

Run this code
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