| rd_missplot | R Documentation |
Generates a visual summary of missing data for variables in a REDCap dataset or list structure. With by = "vars" (default), cross-sectional (single-event) studies get a barplot showing the proportion or count of missing values per variable, and longitudinal studies (with the column redcap_event_name, also with a single event) get a heatmap illustrating missingness across events and variables. With by = "record", the plot shows one row per record and one column per variable, with the missing values painted.
rd_missplot(
data,
sort_by_missingness = TRUE,
max_vars = NULL,
show_percentages = TRUE,
use_field_labels = TRUE,
drop_complete = TRUE,
max_label_length = 40,
by = c("vars", "record"),
events = NULL,
forms = NULL
)
data |
A |
sort_by_missingness |
Logical. Variables are ordered from highest to lowest number of missing values (the count, also when |
max_vars |
Integer. If specified, only |
show_percentages |
Logical. Displays missingness as percentages. Only used with |
use_field_labels |
Logical. Uses field labels from the dictionary for axis labels instead of variable names. Default |
drop_complete |
Logical. Variables with 0 missing values are excluded from the plot. Default |
max_label_length |
Integer. Maximum number of characters of the axis labels: longer labels are shortened. When several variables share a label, their variable name is then added to it in parentheses, so these labels can be longer. Use |
by |
Character. |
events |
Character vector. Only for longitudinal projects: events to plot, by their unique name (e.g. |
forms |
Character vector. Only plot the variables of these forms (instrument names as in the |
With by = "vars", the function automatically detects whether the input dataset contains longitudinal event information. If redcap_event_name is detected in the data columns, a missingness heatmap grouped by event is produced (with by = "record", see below).
When the event-form mapping is available (event_form element of the list), each variable is only evaluated in the events where its form is collected; the other cells of the heatmap are left blank.
With by = "record", longitudinal projects get one panel per event, each with the variables collected in that event. By default only the first event is plotted (with a warning); use events to choose others. Records without data in an event are shown in grey in that event's panel. With repeated instruments and repeating events, each repetition is a row of its own, and the cells of variables that are not collected in that row are shown in light grey. Every row is labelled with its record identifier.
A ggplot2 object representing a missingness barplot, a longitudinal missingness heatmap or a record-level missingness map.
## Not run:
# Missing values per variable and event
rd_missplot(covican)
# Missing values record by record in the baseline laboratory findings
rd_missplot(covican, by = "record", events = "baseline_visit_arm_1",
forms = "laboratory_findings")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.