Uses parse_date_time to transform string vectors with different date formats into an R date vector, printed in ISO format. If only the year is provided, then the date will be set as June 30 of that year.

guessdate(messydate)

Arguments

messydate

Date in the format MM/DD/YYYY, MM/YYYY, or YYYY only.

Value

Date vector in ISO date notation.

Examples

guessdate(c("03/28/2019", "03/2019", "03/19", "2019"))
#> [1] "2019-03-28" "2019-03-20" "2019-03-01" "2019-06-30"