Extracting dates and changing their format in R -
i have vector of dates in format:
dates 20-jun-91 8-mar-89 14-sep-96 19-dec-00 3-feb-95 25-jul-92 i want extract years , add them column:
new dates 1991 1989 1996 2000 na 1995 1992 any date not in format d-m-y should read na.
strptime seems work if dates numerical.
any ideas?
thank all!
try code:
strptime(df$dates, "%d-%b-%y")$year + 1900 using lubridate package:
year(dmy(df$dates))
Comments
Post a Comment