| rd_dates | R Documentation |
Converts date and datetime fields in a REDCap dataset to appropriate R classes.
rd_dates(project = NULL, data = NULL, dic = NULL, event_form = NULL)
project |
A list containing the REDCap data, dictionary, and event mapping (expected |
data |
A |
dic |
A |
event_form |
Only applicable for longitudinal projects (presence of events). Event-to-form mapping for longitudinal projects. |
The function performs the following tasks:
Detects date and datetime fields from the REDCap dictionary (date_* and datetime_* validation types).
Converts date fields to Date class.
Converts datetime fields to POSIXct class, treating empty strings as NA. The texts are read in UTC, whatever the time zone of the session (e.g. TZ = "Europe/Paris"): the time is kept as it is written in REDCap (e.g. 2024-01-05 10:30 is 10:30 UTC). The fields that are already POSIXct are left as they are.
Each value is converted on its own (YYYY-MM-DD or YYYY/MM/DD, with or without time): a value that isn't a date or a
datetime (e.g. a Missing Data Code that wasn't removed) is set to NA, and a warning lists the fields and the values.
A list with the following elements:
The transformed dataset with date and datetime fields formatted as Date and POSIXct.
The original REDCap dictionary passed to the function.
The original event-form mapping (if applicable).
A summary of the transformations performed.
Other process functions:
rd_checkbox(),
rd_delete_vars(),
rd_dictionary(),
rd_factor(),
rd_insert_na(),
rd_recalculate(),
rd_rlogic(),
rd_split(),
rd_transform()
result <- rd_dates(covican)
transformed_data <- result$data
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.