I have a csv dataset that has date of births stored as characters in the format - 01-06-68
("%d-%m-%y"
). I tried to convert the dates to Date
objects using as.Date()
but it identifies the year as 2068
when in fact the year is 1968
. I understand Date
starts from 1970-01-01
in R, is there an easy fix to this?
I am using the lubridate
package to find the age.
Some age were negative due to the wrongly identified year.
elapsed <- train$Date.of.Birth %--% Sys.Date()
train$age <- floor(as.duration(elapsed) / dyears(1))