Learn R Programming

REDCapDM (version 1.0.1)

rd_dictionary: Transform the data dictionary and handle branching logic

Description

[Experimental]

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.

Usage

rd_dictionary(project = NULL, data = NULL, dic = NULL, event_form = NULL)

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.

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:

  • Evaluates and transforms branching logic expressions into valid R expressions using rd_rlogic.

  • Evaluates and converts calculation expressions for fields of type calc.

  • Generates a results summary table listing any variables that could not be converted.

Examples

Run this code
if (FALSE) {
result <- rd_dictionary(covican)
print(result$results)
updated_dic <- result$dictionary
}

Run the code above in your browser using DataLab