{
library(dplyr)
library(tidyr)
##### Example 1 -------------------------------------------------------------
# Ambiguous dates -----------------------------------------------------------
as_any_date('19 02 12')
as_any_date('19 02 12', format = "ymd")
as_any_date('19 02 12', format = "dym")
##### Example 2 -------------------------------------------------------------
# Non-ambiguous dates -------------------------------------------------------
time <-
tibble(time = c(
"1983 07-19",
"14-01-1925",
"12/13/2015",
"2009-09-13",
"17-12-12",
"coucou",
"2025 jan the 30th",
"1809-01-19"))
time %>% mutate(new_time = as_any_date(time))
}
Run the code above in your browser using DataLab