Description Usage Arguments Details Value Examples
Automatically detects date format (including UK vs. US dates) and converts dates to IDate. Uses the pvec function of the parallel package if loaded.
1 2 | textToDate(x, missingformat = c('0000-00-00',
'0000-00-00 00:00:00', '', 'NA'))
|
x |
a string representing a date |
missingformat |
strings which represent missing dates |
The function first tries out different formats on the non-missing values, including US and UK formats (UK is default). It chooses the format which results in valid dates. All dates in the datestring must have the same format.
a vector of class IDate if successful, or the original character string if not.
1 2 3 4 5 6 7 8 9 10 | ##
print(textToDate(c('13/6/1970'))) # UK format
print(textToDate(c('6/13/1970'))) # US format
print(textToDate(c('13/6/1970', '6/13/1970'))) # conflict
print(textToDate(c('2009-07-08', '0000-00-00'))) # with blank
print(textToDate(c('5/6/1970', NA, '7/8/1980'))) # missing
print(textToDate(c('5/6/1970', '', '7/8/1980'))) # blank date
print(textToDate(c('5/6/1970', 'NA', NA, '7/8/1980'))) # missing
print(textToDate(c('5/6/1970', '0000-00-00', NA, '7/8/1980'))) # missing
print(textToDate(c('5/6/1970', '70/5/1980', '7/8/1980'))) # illegal
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.