Learn R Programming

messy (version 0.1.0)

messy_datetime_formats: 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") )

Value

a dataframe the same size as the input data.

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.

Author

Jack Davison

See Also

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

Examples

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

Run the code above in your browser using DataLab