I'm really new to R!
I have the following column CMPLNT_FR_DT in a dataset called crimedata
CMPLNT_FR_DT
12/31/2015
01/23/2009
10/04/2010
05/31/2015
I need to change the column values so that the dates only include the years, like:
CMPLNT_FR_DT
2015
2009
2010
2015
I tried solutions from Extract year from date
but my error returns as
format(as.Date(df$CMPLNT_FR_DT, format="%m/%d/%Y"),"%Y")
Error in df$CMPLNT_FR_DT : object of type 'closure' is not subsettable
I'm not sure what I am doing wrong. I would really appreciate your help!