user4797853 user4797853 - 24 days ago 12
R Question

coercing to date, "%m/%d/%y" yields wrong year

I have used the following code

data$Date <- as.Date(data$Date, "%m/%d/%y")


However when I enter
1/4/2016
the output is
2020-04-01
.

Answer

You want as.Date(a, "%m/%d/%Y"), not as.Date(a, "%m/%d/%y").

Comments