View source: R/generate_queries.R
generate_queries | R Documentation |
Generates two types of data validation queries using the project codebook
(see meta_dictionary
) and translate_logic
:
Field missing: Branching logic evaluates to TRUE
(if specified), but
field is missing. By default only applies to required fields (required_field == "y"
) (can modify with argument non_required
).
Field not missing: Branching logic evaluates to FALSE
but field is
not missing. Applies to any field with branching logic.
generate_queries(
conn,
forms = NULL,
dict = meta_dictionary(conn, forms = forms, expand_checkbox = FALSE),
lang = "en",
query_types = "both",
non_required = FALSE,
drop_redundant = FALSE,
field_nchar_max = 80L,
on_error = "warn"
)
conn |
A REDCap API connection object (created with |
forms |
Character vector of forms (i.e. instruments) to include. Set to
|
dict |
Metadata dictionary. By default is fetched automatically with
|
lang |
Query language, either English ("en") or French ("fr"). Defaults to "en". |
query_types |
Which type of queries to generate (see Description above). Options are "missing", "not missing", or "both". Defaults to "both". |
non_required |
Logical indicating whether to include non-required fields
in queries of type "Field missing". Defaults to |
drop_redundant |
Logical indicating whether to simplify expressions by
removing redundant components from expressions that test both for equality
and inequality with the same variable. E.g.: |
field_nchar_max |
Integer indicating the maximum number of characters to allow in field name labels before they are truncated and appended with "...". Defaults to 80L. |
on_error |
What to do if one or more elements of statements can't be
translated into valid R expressions? Options are "ignore" (return |
A tibble
-style data frame specifying queries, with the
following 7 columns:
Unique query identifier based on form name and integer sequence
Field name (from REDCap dictionary, see meta_dictionary
)
Form name (from REDCap dictionary)
Is it a required field in REDCap dictionary ("y" or <NA>
) ?
Description of query (e.g. "Missing: [Signed consent forms?]")
Suggestion for query resolution. A human-readable translation of query expression (e.g. If [Is the participant 18 years or older?] is "Yes", item [Signed consent forms?] should not be missing)
Branching logic for given field (from REDCap dictionary)
R-style query expression (can be evaluated with queryr::query
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.