| rd_event | R Documentation |
Helps identify records in a REDCap longitudinal project that are missing one or more specified events. Because REDCap typically omits empty events from exports, an event that contains no data for a record will not appear. This function finds those absent events (not whether the events are complete) and returns a per-record query table and a summarized HTML report.
rd_event(
project = NULL,
data = NULL,
dic = NULL,
event_form = NULL,
event,
filter = NA,
query_name = NA,
add_to = NA,
report_title = NA,
report_zeros = FALSE,
link = list(),
addTo = deprecated()
)
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. |
event |
Character vector with one or more REDCap event names to check for missing records. |
filter |
Optional. A single character string containing a filter expression that selects the records to check. Example: |
query_name |
Optional character vector describing each query: one message for all the events, or one message for each event of |
add_to |
Optional output of a previous |
report_title |
Optional string specifying the title of the final report. Defaults to |
report_zeros |
Logical, include events with zero queries in the report. Default is |
link |
Optional list containing project information ( |
addTo |
A list of class REDCapDM_report, which prints a short summary (see print.REDCapDM_report()), with two elements:
queriesA data frame listing records missing the specified events.
Columns: Identifier (the record identifier, record_id or else the first field of the dictionary, which filter can use by its name), DAG, Event (the unique event name), EventLabel (its label), Instrument,
Field, Repetition, Description, Query, Code,
and optionally Link. If no queries are found this will be an empty
data frame with the expected columns.
resultsAn HTML table (knitr::kable styled with kableExtra) summarising
the number of missing records per event. Returned as knitr::kable (HTML).
Other query functions:
check_queries(),
rd_export(),
rd_query()
# Minimal reproducible example
data0 <- data.frame(
record_id = c("100-1", "100-2", "200-1"),
redcap_event_name = c("baseline_arm_1", "baseline_arm_1", "follow_up_arm_1"),
redcap_event_name.factor = factor(c("Baseline", "Baseline", "Follow-up")),
stringsAsFactors = FALSE
)
# Suppose we want to check that every record has the follow-up event
res <- rd_event(
data = data0,
dic = data.frame(), # placeholder dictionary
event = "follow_up_arm_1",
report_zeros = TRUE
)
# Records missing the event:
res$queries
# HTML summary (in RMarkdown or Viewer)
res$results
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.