View source: R/rd_dictionary.R
| rd_dictionary | R Documentation |
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.
rd_dictionary(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:
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] >= 3 or [a] + [b] after rd_factor()): it can't be written as R logic of the factors. rd_rlogic() and rd_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.
A list with the following elements:
The original dataset passed to the function.
The updated data dictionary with modified branching logic and calculations.
The original event-form mapping (if applicable).
A summary of the transformations, including any variables with unconverted branching logic.
Other process functions:
rd_checkbox(),
rd_dates(),
rd_delete_vars(),
rd_factor(),
rd_insert_na(),
rd_recalculate(),
rd_rlogic(),
rd_split(),
rd_transform()
## Not run:
result <- rd_dictionary(covican)
print(result$results)
updated_dic <- result$dictionary
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.