Description Usage Arguments Details Value Slow call See Also Examples
This function takes a data.frame, checks all its variables for potential dates and transform potential date variables to dates.
1 2 3 4 5 6 7 8 |
x |
a data.frame, numeric vector or character vector, possibly with potential date variable(s) |
... |
arguments passed to |
progress_bar |
Should a progress bar be printed to show the progress of
the call? |
rtr |
Should dates in formats found in RTR be recognised as dates. This
controls |
yyww, yyyyww |
Should entries of the old yyww/yyyyww-formats be
recognised as dates? Same as |
yyyy0000, yyyymm00 |
Should entries with unknown month and/or day (set to
zero) be accepted as dates? If yes, dates in the form "yyyy0000" will be
set to "yyyy0701" and "yyyymm00" to "yyyymm15". Same as |
ask, name |
arguments passed to |
The function only recognise dates in the standard format used in INCA and Rockan, hence ' week number sometimes used for older data). We hope that this older format can be omited in the future since it adds some unclarity if the vector is really a date or not). Dates in other formats (for example as parts of social security numbers, as part of a comment, or as a time stamp) will not be treated as dates.
the given input with potantial date variable(s) converted to date(s) and other variable(s) intact
Note that the function call can be very slow for big data sets (each individual cell is checked). You probably only run this function once per dataset and could hopefully live with this drawback :-)
as.Date
1 2 3 4 5 6 7 8 9 10 11 12 | # Let's say we have a data.frame with one date column and one column that is almost
# (but not excactly) a date:
test_data <- data.frame(
not_date = c("19121212", "1912-12-12", "2014-01-01", "121212"),
date = c(19121212, "1912-12-12", "2014-01-01", "6405"))
as.Dates(test_data) # Only recognizes the "date" column as date
# Inform that the "not_date" column might also be a date candidate if fixed:
as.Dates(test_data, threshold = .5)
# Force the not_date column to date
as.Dates(test_data, threshold = .5, force = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.