View source: R/rd_delete_vars.R
| rd_delete_vars | R Documentation |
Deletes selected variables from a REDCap dataset and its dictionary, keeping them consistent and preserving variable labels.
rd_delete_vars(
project = NULL,
data = NULL,
dic = NULL,
event_form = NULL,
vars = NULL,
pattern = NULL,
forms = 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. |
vars |
Optional. A character vector of variable names to remove from both the dataset and dictionary. |
pattern |
Optional. A character vector of regular expression patterns. Variables matching these patterns will be removed from the dataset and dictionary. |
forms |
Optional. A character vector of form names (as in the |
Ensure that at least one of vars, pattern or forms is specified.
Removes specified variables and their factor versions (e.g., variable.factor) from the dataset.
Removes matching variables from the dictionary.
Warns about factor versions of variables matching patterns, recommending use of rd_factor() if necessary.
With forms, every variable of the form is removed: its factor versions, checkbox options, recalculated versions (_recalc) and the form's _complete and _timestamp fields. The record identifier is always kept. The forms are also removed from event_form, and so are the rows of the repeating instruments among them.
A list containing:
The updated dataset with specified variables removed.
The updated REDCap dictionary.
The event-form mapping (if applicable), without the removed forms.
A summary message describing the variable removal operation.
Other process functions:
rd_checkbox(),
rd_dates(),
rd_dictionary(),
rd_factor(),
rd_insert_na(),
rd_recalculate(),
rd_rlogic(),
rd_split(),
rd_transform()
# Delete specific variables by name
result <- rd_delete_vars(
project = covican,
vars = c("potassium", "leuk_lymph")
)
# Delete variables matching patterns (here, the inclusion and exclusion criteria)
result <- rd_delete_vars(
data = covican$data,
dic = covican$dictionary,
pattern = c("^inc_", "^exc_")
)
# Delete every variable of a form
result <- rd_delete_vars(
project = covican,
forms = "laboratory_findings"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.