i have a csv data that I am in the process of cleaning,
and it contains date columns with xxx_date as part of the column name, however, the entries (straight from CSV) has mm/dd/yyyy or mm/dd/yy format. So in case of yy format, there can either 2/2/01 or 2/2/97, which would each indicate year 2001 or 1997.
I was hoping someone can help me write a function to automatically recognize the word "date" contained in variable column name and change these entries into date format (despite the heterogeneity)
i've tried this:
date_cols <- grep('date$', names(xdb6)) # gets all column indices with word date contained in the title
xdb6[date_cols] <- lapply(xdb6[date_cols], (as.Date)) #stuck here
but doesn't work,
anyway that i can do this?
Thanks
DL