library(dplyr)
library(lubridate)
tibble(
file = c("a", "b", "b", "a"),
dates = c("2020-01-01", "01-jan-2020", "15-mar-2020", "2020-03-15")
) %>%
mutate(dates_clean = parse_date_time(dates, orders = c("ymd", "dmy")))
#> # A tibble: 4 x 3
#> file dates dates_clean
#> <chr> <chr> <dttm>
#> 1 a 2020-01-01 2020-01-01 00:00:00
#> 2 b 01-jan-2020 2020-01-01 00:00:00
#> 3 b 15-mar-2020 2020-03-15 00:00:00
#> 4 a 2020-03-15 2020-03-15 00:00:00
Created on 2022-05-09 by the reprex package (v2.0.1)