Learn R Programming

vald.extractor (version 0.1.1)

calculate_age: Add Age Variable to Dataset

Description

Calculates age in years based on date of birth and test date. Handles missing dates gracefully.

Usage

calculate_age(
  data,
  dob_col = "dateOfBirth",
  test_date_col = "Testdate",
  output_col = "age"
)

Value

Data frame with added age column.

Arguments

data

Data frame containing date columns.

dob_col

Character. Name of date of birth column. Default is "dateOfBirth".

test_date_col

Character. Name of test date column. Default is "Testdate".

output_col

Character. Name for the new age column. Default is "age".

Details

Calculate Age from Date of Birth and Test Date