Add Year Column to Dataset
construct_year.Rd
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.
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