Updates a REDCap data dictionary by converting branching logic and calculation expressions into valid R expressions. This ensures that conditional display rules and calculated fields in the dictionary can be programmatically evaluated with the dataset. Any variables that cannot be converted are reported in the results.
Arguments
- project
A list containing the REDCap data, dictionary, and event mapping (expected
redcap_data()output). Overridesdata,dic, andevent_form.- data
A
data.frameortibblewith the REDCap dataset.- dic
A
data.framewith the REDCap dictionary.- event_form
Only applicable for longitudinal projects (presence of events). Event-to-form mapping for longitudinal projects.
Value
A list with the following elements:
- data
The original dataset passed to the function.
- dictionary
The updated data dictionary with modified branching logic and calculations.
- event_form
The original event-form mapping (if applicable).
- results
A summary of the transformations, including any variables with unconverted branching logic.
Details
The function performs the following tasks:
Evaluates and transforms branching logic expressions into valid R expressions using
rd_rlogic.Evaluates and converts calculation expressions for fields of type
calc.Keeps in REDCap syntax, with the codes of the options, the logic that uses as a number a variable already converted into a factor (e.g.
[score] >= 3or[a] + [b]afterrd_factor()): it can't be written as R logic of the factors.rd_rlogic()andrd_query()evaluate it with the codes, as REDCap does. The same happens with the logic that uses variables of other events.Generates a results summary table listing any variables that could not be converted.
See also
Other process functions:
rd_checkbox(),
rd_dates(),
rd_delete_vars(),
rd_factor(),
rd_insert_na(),
rd_recalculate(),
rd_rlogic(),
rd_split(),
rd_transform()
Examples
if (FALSE) { # \dontrun{
result <- rd_dictionary(covican)
print(result$results)
updated_dic <- result$dictionary
} # }
