I am sorry but I struggle with this:
mydate <- factor("2016-10-25")
as.Date(mydate, format = "%Y-%M-%D")
it returns NA. Any ideas? Thanks!
I am sorry but I struggle with this:
mydate <- factor("2016-10-25")
as.Date(mydate, format = "%Y-%M-%D")
it returns NA. Any ideas? Thanks!
You need to use small letters for month and day ("%Y-%m-%d"
) instead of capital letters ("%Y-%M-%D"
).
mydate <- factor("2016-10-25")
as.Date(mydate, format = "%Y-%m-%d")
"2016-10-25"
You can use lubridate
as follows:
mydate <- factor("2016-10-25")
require(lubridate)
ymd(mydate)