I'm trying to convert my year variable into a Date
class
year type sum
1 99 NON-ROAD 522.9400
2 99 NONPOINT 2107.6250
3 99 ON-ROAD 346.8200
4 99 POINT 296.7950
5 02 NON-ROAD 240.8469
6 02 NONPOINT 1509.5000
The class of year
is chr.
Each time I use as.Date(df$year, "%y")
it returns
[1] "1999-12-23" "1999-12-23" "1999-12-23" "1999-12-23" "2002-12-23" "2002-12-23".....
I only want to change the class, not the format, retaining the 2-digit YR formatting.
How can I change the class, but maintain the formatting, of the year
variable?