rd_insert_na {REDCapDM} | R Documentation |
Insert missing using a filter
Description
Function that allows you to manually input a missing to some variables ('vars') when some filters ('filter') are satisfied. Useful for checkboxes without a gatekeeper question in the branching logic. Take in account that the variable will be transformed only in the events where both the variable and the filter evaluation are present, so they need to have at least one event in common.
Usage
rd_insert_na(..., data = NULL, dic = NULL, event_form = NULL, vars, filter)
Arguments
... |
List containing the data and the dictionary and the event if it's needed. Can be the output of the function 'redcap_data'. |
data |
Data frame containing data from REDCap. If the list is specified this argument is not needed. |
dic |
Data frame containing the dictionary read from REDCap. If the list is specified this argument is not needed. |
event_form |
Data frame containing the correspondence of each event with each form. If the list is specified this argument is not needed. |
vars |
Character vector containing the names of those variables to transform. |
filter |
Character vector containing the logic to be directly evaluated. When each logic is TRUE the corresponding variable specified in 'vars' will be put to missing. |
Value
transformed data with the specified variables converted.
Examples
table(is.na(covican$data$potassium))
data <- rd_insert_na(covican,
vars = "potassium",
filter = "age < 65")
table(data$potassium)