I have a data frame called "div" where the "started_date" column (corresponds to the 3rd column) has a character format like "yyyy-mm-dd".
I formatted all the entries in this column to set everything as dates in the following way:
div$started_date<-ymd(div$started_date)
So my question is: if I try to determine the year for the first entry like year(div$started_date[1])
it prints the year, though if I use year(div[1,3])
the following message is printed in the console:
Error in as.POSIXlt.default(x, tz = tz(x)) :
do not know how to convert 'x' to class “POSIXlt”
Your help is much appreciated.