i have a dataframe with dates in different formats.
want to first only remove 19 in the year of those that have it and use as.POSIXlt to convert the dates.
but the gsub isn't picking up
df.DOB <- c("12/11/99", "10/24/67", "8/18/13", "2/29/45", "2/28/63", "12/14/77",
"07/25/1923", "01/07/1989", "09/02/1974")
gsub("\\/19.*", "", df.DOB)
# [1] "12/11/99" "10/24/67" "8/18/13" "2/29/45" "2/28/63" "12/14/77" "07/25" "01/07" "09/02"
df.DOB.formatted <- as.POSIXlt(df.DOB, format = "%m/%d/%y")
df.DOB.formatted <- df.DOB.formatted - 100L
df.DOB.formatted
# [1] "1999-12-10 23:58:20 EST" "2067-10-23 23:58:20 EDT" "2013-08-17 23:58:20 EDT"
# [4] NA "2063-02-27 23:58:20 EST" "1977-12-13 23:58:20 EST"
# [7] "2019-07-24 23:58:20 EDT" "2019-01-06 23:58:20 EST" "2019-09-01 23:58:20 EDT"
would be grateful for your help
thanks