age_cal: Age Calculator

Description Usage Arguments Value Examples

View source: R/variable_operations.R

Description

Calculate age variable in years from an existing calendar year variable in dataset by subtracting year variable from System Date

Usage

1
age_cal(data, variable)

Arguments

data

name of dataset

variable

variable name whose age is to be calculated

Value

a dataframe with age as a vector

Examples

1
2
3
4
5
csv = system.file("extdata", 'agedata.csv', package = "nacleanR")
agedata <- read_data(csv)
agedata$ageTodaySinceBuilt <- age_cal(agedata,"YearBuilt")
agedata$ageTodaySinceRenovated <- age_cal(agedata, "YearRenovated")
head(agedata)

anandjage/nacleanr documentation built on July 13, 2019, 3:06 a.m.