As the title already state I am dealing with the minute data in the following format:
head(data$time)
[1] "11/10/2019 12:20" "10/10/2019 13:10" "03/01/2020 13:12" "11/10/2018 17:46"
I would like to ideally omit the HH:MM from the entry, and was wondering what the most efficient approach would be.
CodePudding user response:
A possible solution, using package anytime:
anytime::anydate("11/10/2019 12:20")
#> [1] "2019-11-10"
CodePudding user response:
With lubridate package you have to parse the date time format (lubridate::dmy_hm), then you can extract date part only (as_date):
d <- "11/10/2019 12:20"
lubridate::as_date(lubridate::dmy_hm(d))
lubridate::as_date(d) only is not ok it gives "2011-10-20"
