query_vec | R Documentation |
Data validation queries with query
or query_list
, but vectorized over
a set of query expressions in string format (and optionally a corresponding
vector of query names/IDs). Results of the multiple queries are stacked and
returned in a single tidy data frame, with columns referenced in the query
expressions pivoted to long-form (e.g. "variable1", "value1", "variable2",
"value2", ...).
query_vec(
x,
cond,
element,
name,
cols_base,
name_col = "query_id",
join_type = "left",
join_by = NULL,
pivot_var = "variable",
pivot_val = "value",
as_chr = TRUE
)
x |
A data frame or a list of data frames to query. If a single data
frame will vectorize with |
cond |
Character vector of expressions to evaluate with respect to
variables within |
element |
If |
name |
(Optional) Character vector giving query names/IDs for each of
the expressions within |
cols_base |
(Optional) Tidy-selection of other columns within |
name_col |
Column name for the query names/IDs. Defaults to "query_id". |
join_type |
If |
join_by |
A character vector of variables to join by, or list of vectors
the same length as |
pivot_var |
Prefix for pivoted variable column(s). Defaults to "variable". |
pivot_val |
Prefix for pivoted value column(s). Defaults to "value". |
as_chr |
Logical indicating whether to coerce the columns referenced in
the query expression(s) to character prior to returning. This enables
row-binding multiple queries with variables of different classes. Defaults
to |
A data frame reflecting the rows of data
that match the given queries.
Returned columns include:
query name/ID column (name taken from argument name_col
)
(optional) columns matched by argument cols_base
columns referenced within the query expressions, pivoted to long form
query
data(ll) # example dataset, an epidemiological linelist
data(ll_queries) # example data frame defining queries to run on ll
# run all queries defined in ll_queries
query_vec(
ll,
cond = ll_queries$query,
name = ll_queries$query_id,
cols_base = c(id, site)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.