Description Usage Arguments Details Examples
This function is a wrapper for the as.POSIXct function. This function is designed require less effort.
1 2 | reformatTime(dateToReformat, timeIfSeparateFromDate = NULL,
dateFormat = NULL, tz = "Etc/GMT+6", defaultStyle = "american", ...)
|
dateToReformat |
the date and or time an event occured |
timeIfSeparateFromDate |
the time of an event as a character array |
dateFormat |
either ("american", "british", "international") or the strptime format parameter. |
tz |
time zone to use |
defaultStyle |
if an indeterminate date is found then the default style is used (either american or british, international dates are usually not indeterminant because of the leading year) |
The format parameter can be identical to the as.POSIXct function parameter or it can be simplified to simply "american", "british", or "international".
The function identifies the format from knowledge of the order.
The user identifies which format order. This code will issue a warning if an obvious issue occurs with the format. If the dataset is large getting the format is critical as testing is limited to the first 100 datapoints.
testChararacterDate parameters may be entered into the function
If dateformat is blank the system will guess at the date format.
Because the American and British styles can be confused it may be necissary to specify the format.
dateformat = "American" ... date order is (1) mm (2) day (3) year dateformat = "British" ... date order is (1) day (2) mm (3) year dateformat = "International" ... date order is (1) year (2) mm (3) day
The time of day may not be part of the character string included with the date. If it is not then the timeIfSeparateFromDate paramter can include a text string with the time.
This function does not work if the data is already converted to a POSIXct time format.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
reformatTime("1/31/2012T00:00:00")
reformatTime("2018-01-05 13:45:01")
# This will generate a warning because it could be either
# American or British format
reformatTime("01-01-2010 12:00:00")
reformatTime("01-01-2010 12:00:00", dateFormat = "American")
reformatTime("4/30/2018 15:07", dateFormat = "American")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.