ToDateCleaner: Invalid date string parsing

Description Usage Arguments Examples

View source: R/format-text.R

Description

This function is a wrapper for ToDate that takes a character string of integers of length 4 to 8 and attempts to parse out a valid date.

Usage

1
2
3
4
5
6
7
ToDateCleaner(
  datestring,
  method = "ymd",
  fallback_mo = 1,
  fallback_day = 1,
  debug = FALSE
)

Arguments

datestring

Numeric string of length 1-8 to interpret

method

Position of year, month, day values within the string. Currently ONLY ymd is supported!

fallback_mo

Month number to insert, if necessary

fallback_day

Day number to insert, if necessary

debug

If TRUE, print debug output

Examples

1
2
3
4
5
6
weird_dates <- c('20200101', '2020', '20201', '202001', '20200000'
, '2020001', '20200001', '20200199')

# ToDate returns errors
# But ToDateCleaner attempts to fix the invalid date strings
ToDateCleaner(weird_dates)

phively/wranglR documentation built on April 11, 2020, 5:12 a.m.