| reference_rule | R Documentation |
Creates a rule that checks whether values in a local column exist in a
column of a referenced dataset. Use with check_data() by supplying x as
a named list of datasets and setting data_name in ruleset() (or by
ordering the list so the first entry is the primary dataset).
reference_rule(
local_col,
ref_dataset,
ref_col,
name = NA,
allow_na = FALSE,
negate = FALSE,
...
)
local_col |
column name in the primary dataset. |
ref_dataset |
name of the referenced dataset in the |
ref_col |
column name in the referenced dataset. |
name |
optional display name for the rule. |
allow_na |
logical; if |
negate |
logical; if |
... |
additional fields attached to the rule object. |
A reference_rule object that can be included in ruleset().
flights <- data.frame(carrier = c("AA", "BB", NA_character_))
carriers <- data.frame(carrier_id = c("AA"))
rs <- ruleset(
reference_rule(
local_col = "carrier",
ref_dataset = "carriers",
ref_col = "carrier_id",
allow_na = TRUE
),
data_name = "flights"
)
check_data(list(flights = flights, carriers = carriers), rs)
# negated relation: value must NOT exist in blacklist
blacklist <- data.frame(carrier_id = c("XX", "YY"))
rs_neg <- ruleset(
reference_rule(
local_col = "carrier",
ref_dataset = "blacklist",
ref_col = "carrier_id",
negate = TRUE,
allow_na = TRUE
),
data_name = "flights"
)
check_data(list(flights = flights, blacklist = blacklist), rs_neg)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.