Description Usage Arguments Details Value Note See Also Examples

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 function is applied to 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.

1 2 3 4 5 | ```
assert_rows(data, row_reduction_fn, predicate, ...,
success_fun = success_continue, error_fun = error_stop)
assert_rows_(data, row_reduction_fn, predicate, ..., .dots,
success_fun = success_continue, error_fun = error_stop)
``` |

`data` |
A data frame |

`row_reduction_fn` |
A function that returns a value for each row of the provided data frame |

`predicate` |
A function that returns FALSE when violated |

`...` |
Comma separated list of unquoted expressions.
Uses dplyr's |

`success_fun` |
Function to call if assertion passes. Defaults to
returning |

`error_fun` |
Function to call if assertion fails. Defaults to printing a summary of all errors. |

`.dots` |
Use assert_rows_() to select columns using standard evaluation. |

For examples of possible choices for the `success_fun`

and
`error_fun`

parameters, run `help("success_and_error_functions")`

By default, the `data`

is returned if predicate assertion
is TRUE and and error is thrown if not. If a non-default
`success_fun`

or `error_fun`

is used, the return
values of these function will be returned.

See `vignette("assertr")`

for how to use this in context

`insist_rows`

`assert`

`verify`

`insist`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
# returns mtcars
assert_rows(mtcars, num_row_NAs, within_bounds(0,2), mpg:carb)
library(magrittr) # for piping operator
mtcars %>%
assert_rows(rowSums, within_bounds(0,2), vs:am)
# anything here will run
## Not run:
mtcars %>%
assert_rows(rowSums, within_bounds(0,1), vs:am)
# the assertion is untrue so
# nothing here will run
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.