clean_dates: Clean messy date variables

Description Usage Arguments Details Author(s)

View source: R/clean_dates.R

Description

Clean messy date variables

Usage

1
clean_dates(x, quietly = FALSE)

Arguments

x

a vector of dates to be cleaned

quietly

a TRUE/FALSE of whether to show warnings for dropped observations (default is FALSE, so warnings are shown)

Details

Any observation with only text will be set to missing (NA). Properly spelt text names of months will be translated from French and Portuguese to English. If there is a date and year along with the month name this will be changed to an appropriate date (nb. if there is an ending to date e.g. 1st, 2nd etc. this will not work).

Dates imported from Excel are identified by containing 5 numbers and starting with the number 4. This will only work for dates after July 2009 and before November 2036.(This could be updated to attempt all those containing any 5 numbers).

Anything else in a date formate will be kept; regardless of the separator (dots, slashes or dashes).

All observations are then passed through lubridate::parse_date_time() to produce appropriate dates.

Author(s)

Alice Carr, Alex Spina


R4IDSR/covidmonitor documentation built on March 29, 2021, 12:05 p.m.