rd_dates: Transform Dates and Datetimes in REDCap Data
Description
![[Experimental]](figures/lifecycle-experimental.svg?package=REDCapDM&version=1.0.1)
Converts date and datetime fields in a REDCap dataset to appropriate R classes.
Usage
rd_dates(project = NULL, data = NULL, dic = NULL, event_form = NULL)
Value
A list with the following elements:
- data
The transformed dataset with date and datetime fields formatted as Date and POSIXct.
- dictionary
The original REDCap dictionary passed to the function.
- event_form
The original event-form mapping (if applicable).
- results
A summary of the transformations performed.
Arguments
- project
A list containing the REDCap data, dictionary, and event mapping (expected redcap_data() output). Overrides data, dic, and event_form.
- data
A data.frame or tibble with the REDCap dataset.
- dic
A data.frame with the REDCap dictionary.
- event_form
Only applicable for longitudinal projects (presence of events). Event-to-form mapping for longitudinal projects.
Details
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.
Examples
Run this coderesult <- rd_dates(covican)
transformed_data <- result$data
Run the code above in your browser using DataLab