rc_missing: Find missing record data

View source: R/rc_missing.R

rc_missingR Documentation

Find missing record data

Description

Finds data points which are ostensibly missing from Redcap records data.

For each event/variable combination, if a value exists for at least one record then it is expected to exist for all records. Any event or variable which is empty within the entire dataframe will inherently be dropped. If an event has no values for a given record, none of the variables will be flagged unless there is data for that record in the following event. Additionally, if the subject is marked as having completed the study (i.e. completion_field == 'Yes'|1), then empty events for that subject will not be discarded.

The logic of this function does not extend to repeat instruments or checkbox, calculated, or hidden fields. If present in the record data, they will be dropped. Additionally, this function does not yet support branching logic. Any field with logic dependent on another field will be removed. Fields with other logic, ie event based logic, will remain.

Usage

rc_missing(
  record_data,
  completion_field = NULL,
  repeats = NULL,
  data_dict = getOption("redcap_bundle")$data_dict,
  events = getOption("redcap_bundle")$event_data$unique_event_name,
  form_perm = getOption("redcap_bundle")$form_perm,
  mappings = getOption("redcap_bundle")$mappings,
  id_field = getOption("redcap_bundle")$id_field
)

Arguments

record_data

Record data export from REDCap

completion_field

Character. The REDCap variable which indicates whether or not a subject has completed the study. This should be indicated by a 'Yes' or a '1' (i.e. a Yes/No field in REDCap). If not provided, some missing data may be lost.

repeats

Character. A vector of repeat instrument names which should be kept. This should ONLY be used for repeat instruments which are expected to have a consistent number of occurrences per each event/ID combination. All repeat instruments not supplied here will be removed to avoid excessive false positives.

data_dict

Dataframe. REDCap project data data_dictionary. By default, $data_dict is expected in a REDCap bundle object, as created by rc_bundle. Otherwise, an equivalent data.frame containing the project data dictionary must be supplied.

events

Character. Vector of REDCap event names. Events not included in this list will not be considered. If supplying manually, chronological ordering of events must be ensured.

form_perm

Dataframe. User access permissions for REDCap forms. By default, $form_perm is expected in the REDCap bundle, as created by rc_bundle. Otherwise, an equivalent data.frame containing form permission data must be supplied.

mappings

Dataframe. Redcap metadata that maps forms to events.

id_field

Character. The name of the record_id field for your REDCap project.

Author(s)

Marcus Lehr


chillywings/rctools documentation built on Aug. 9, 2024, 11:52 p.m.