datemunge: Convert date text strings into YYY-MM-DD

Description Usage Arguments Value Examples

Description

Convert month/day/year date stamps, like 5/31/2016, or other permutations of those positions (e.g., 31/5/2016, 2016/5/31), to the ISO 8601 standard of YYY-MM-DD. Any NA values in output that do not have associated blank or NA values in input trigger an error. This is just a wrapper around as.Date to help with formatting and error checking.

Usage

1
datemunge(datetxt, ord_input = c("M", "D", "Y"))

Arguments

datetxt

character vector of dates

ord_input

character vector containing the values "M", "D", and "Y" ordered to specify the month, date, and year fields

Value

character vector of ISO 8601-formatted date stamps

Examples

1
2
3
4
dates <- c("5/31/2016", "10/1/2018", "1/2/2019")
datemunge(dates)
dates_euro <- c("31/5/2016", "1/10/2018", "2/1/2019")
datemunge(dates_euro, ord_input = c("D", "M", "Y"))

ressy/srahelper documentation built on May 29, 2019, 11:03 p.m.