Raises error if dynamically created predicate is FALSE for any row after applying row reduction functionSource:
Meant for use in a data analysis pipeline, this function applies a function to a data frame that reduces each row to a single value. Then, a predicate generating function is applied to row reduction values. It will then use these predicates to check each of the row reduction values. If any of these predicate applications yield FALSE, this function will raise an error, effectively terminating the pipeline early. If there are no FALSEs, this function will just return the data that it was supplied for further use in later parts of the pipeline.
insist_rows( data, row_reduction_fn, predicate_generator, ..., success_fun = success_continue, error_fun = error_stop, skip_chain_opts = FALSE, obligatory = FALSE, defect_fun = defect_append, description = NA )
A data frame
A function that returns a value for each row of the provided data frame
A function that is applied to the results of the row reduction function. This will produce, a true predicate function to be applied to every element in the vector that the row reduction function returns.
Comma separated list of unquoted expressions. Uses dplyr's
selectto select columns from data.
Function to call if assertion passes. Defaults to returning
Function to call if assertion fails. Defaults to printing a summary of all errors.
error_funare used even if assertion is called within a chain.
If TRUE and assertion failed the data is marked as defective. For defective data, all the following rules are handled by
Function to call when data is defective. Defaults to skipping assertion and storing info about it in special attribute.
Custom description of the rule. Is stored in result reports and data.
By default, the
data is returned if dynamically created
predicate assertion is TRUE and and error is thrown if not. If a
error_fun is used, the
return values of these function will be returned.
For examples of possible choices for the
error_fun parameters, run
vignette("assertr") for how to use this in context