messy-date-fmt: Make date(time) formats inconsistent

messy_datetime_formatsR Documentation

Make date(time) formats inconsistent

Description

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.

Author(s)

Jack Davison

See Also

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

Examples

data <- data.frame(dates = rep(Sys.Date(), 10))
messy_date_formats(data)

messy documentation built on April 3, 2025, 6:16 p.m.