Description Usage Arguments Value Warning Examples
Cleans different formats of date strings and converts them to a uniform date format "%Y-%m-%d" as returned by as.Date(). Year must be in last position. If it encounters a swap in month and day position it swaps them around.
1 | clean_date(date_vec, unresolved = FALSE)
|
date_vec |
A vector of strings |
unresolved |
TRUE returns a list including a vector of unresolved values. |
If unresolved is set to true returns a list containing two elements: $Date is a vector of strings with the cleaned or otherwise untouched input data and $unresolved is a logical vector with FALSE if a value was changed and TRUE otherwise. If unresolved is false, only the date vector will be returned.
Produces NA if year is in first position and date does not follow the formatting convention of as.Date.
1 2 3 4 5 6 7 8 9 | clean_date("24.12.2000")
clean_date("24/12/00")
clean_date("12/24/00")
clean_date("12 /2 /2016")
clean_date("12 /2 /2016", unresolved=TRUE)$unresolved
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.