Skip to contents

Takes any date(times) column and transforms it into a character column, sampling from any number of random of valid character representations.

Usage

messy_datetime_formats(
  data,
  cols = NULL,
  formats = c("%Y/%m/%d %H:%M:%S", "%d/%m/%Y %H:%M:%S")
)

messy_date_formats(
  data,
  cols = NULL,
  formats = c("%Y/%m/%d", "%d/%m/%Y")
)

Arguments

data

input dataframe

cols

set of columns to apply transformation to. If NULL will apply to all POSIXt columns (for messy_datetime_formats()) or Date columns (for messy_date_formats()).

formats

A vector of any number of valid strptime() formats. Multiple formats will be sampled at random.

Value

a dataframe the same size as the input data.

See also

Other Messy date(time) functions: messy_datetime_tzones(), split_datetimes()

Author

Jack Davison

Examples

data <- data.frame(dates = rep(Sys.Date(), 10))
messy_date_formats(data)
#>         dates
#> 1  03/12/2024
#> 2  2024/12/03
#> 3  2024/12/03
#> 4  2024/12/03
#> 5  2024/12/03
#> 6  2024/12/03
#> 7  2024/12/03
#> 8  2024/12/03
#> 9  03/12/2024
#> 10 2024/12/03