| rd_transform | R Documentation |
Transforms the raw REDCap data read by the redcap_data function. The function runs in one-step pipeline the functions dedicated to processing the data (rd_delete_vars(), rd_dates(), rd_recalculate(), rd_checkbox(), rd_factor(), rd_dictionary() and, with final_format, rd_split()) and returns the transformed data and dictionary, along with a summary of each step done. rd_insert_na() is not part of it: its filters are specific to each project, so apply it separately.
rd_transform(
project = NULL,
data = NULL,
dic = NULL,
event_form = NULL,
checkbox_labels = c("No", "Yes"),
na_logic = "none",
exclude_recalc = NULL,
exclude_factor = NULL,
delete_vars = NULL,
delete_pattern = NULL,
final_format = "raw",
which_event = NULL,
which_form = NULL,
wide = 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. |
checkbox_labels |
Character vector of length 2 for labels of unchecked/checked values. Default: |
na_logic |
Controls how missing values are set based on the branching logic of a checkbox. Must be one of |
exclude_recalc |
Optional. Character vector of field names to exclude from recalculation. |
exclude_factor |
Optional character vector of variable names (use original names without the |
delete_vars |
Optional. A character vector of variable names to remove from both the dataset and dictionary. |
delete_pattern |
Optional. A character vector of regular expression patterns. Variables matching these patterns will be removed from the dataset and dictionary. |
final_format |
Character string indicating the final format of the data. Options are |
which_event |
Character. If |
which_form |
Character. If |
wide |
Logical. If |
A list with elements:
Transformed data. With final_format = "by_event" or "by_form", as in rd_split(): a tibble with one row per event or form and its dataset in the list-column df (e.g. trans$data$df[[1]]), or the data.frame of the event or form chosen with which_event or which_form.
Updated dictionary data.frame.
Event–form mapping (if applicable).
Character summary of transformation steps performed.
Other process functions:
rd_checkbox(),
rd_dates(),
rd_delete_vars(),
rd_dictionary(),
rd_factor(),
rd_insert_na(),
rd_recalculate(),
rd_rlogic(),
rd_split()
# Minimal usage (project object or data + dictionary)
trans <- rd_transform(covican)
# Custom checkbox labels
trans <- rd_transform(covican,
checkbox_labels = c("Not present", "Present"))
# Return only a single form (wide)
trans <- rd_transform(covican,
final_format = "by_form",
which_form = "laboratory_findings",
wide = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.