How to create date from datetime (using lubridate)?
You can just use round_date
round_date(a, "day")
[1] "2014-01-02 UTC"
EDIT
You do need to be careful with rounding the time though. For complete equivalence here you would need to use floor_date
.
identical(ymd("2014-01-01"), floor_date(a, "day"))
[1] TRUE
Using date()
is much shorter and avoids any issues with rounding.
library(lubridate)
date(a)
[1] "2014-01-01"