This function is called in prep_data and so shouldn't usually need to be called directly. It tries to convert columns ending in "DTS" to type Date. It makes a best guess at the format and return a more standard one if possible. Times are be removed.

convert_date_cols(d)

Arguments

d

A dataframe or tibble containing data to try to convert to dates.

Value

A tibble containing the converted date columns. If no columns needed conversion, the original data will be returned.

Examples

d <- tibble::tibble(a_DTS = c("2018-3-25", "2018-3-25"), b_nums = c(2, 4), c_DTS = c("03-01-2018", "03-07-2018"), d_chars = c("a", "b"), e_date = lubridate::mdy(c("3-25-2018", "3-25-2018"))) convert_date_cols(d)
#> # A tibble: 2 x 5 #> a_DTS b_nums c_DTS d_chars e_date #> <date> <dbl> <date> <chr> <date> #> 1 2018-03-25 2. 2018-03-01 a 2018-03-25 #> 2 2018-03-25 4. 2018-03-07 b 2018-03-25