Skip to contents

This function takes a dataset with a specified date column and returns the dataset with an additional column `dobyr` which contains the year extracted from the date column.

Usage

construct_year(dataset, date_col = "birth1c", year_col = "dobyr")

Arguments

dataset

A data frame containing at least one column with date values.

date_col

The name of the column containing date values. Default is `"birth1c"`.

year_col

The name of the column containing year values. Default is `"dobyr"`.

Value

A data frame with an additional column `dobyr` containing the year of the date column.

Examples

df <- data.frame(birth1c = c("1990-05-15", "1985-10-30", "2000-07-22"))
new_df <- add_year_column(df)
#> Error in add_year_column(df): could not find function "add_year_column"
print(new_df)
#> Error: object 'new_df' not found

df <- data.frame(event_date = c("1990-05-15", "1985-10-30", "2000-07-22"))
new_df <- add_year_column(df, date_col = "event_date")
#> Error in add_year_column(df, date_col = "event_date"): could not find function "add_year_column"
print(new_df)
#> Error: object 'new_df' not found