assert_filter_cond: Is an Argument a Filter Condition?

Description Usage Arguments Details Value Author(s) Examples

View source: R/assertions.R

Description

Is an Argument a Filter Condition?

Usage

1
assert_filter_cond(arg, optional = FALSE)

Arguments

arg

Quosure - filtering condition.

optional

Logical - is the argument optional? Defaults to FALSE.

Details

Check if arg is a suitable filtering condition to be used in functions like subset or dplyr::filter.

Value

Performs necessary checks and returns arg if all pass. Otherwise throws an informative error.

Author(s)

Ondrej Slama

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(admiral.test)
data(dm)

# typical usage in a function as a parameter check
example_fun <- function(dat, x) {
  x <- assert_filter_cond(rlang::enquo(x))
  dplyr::filter(dat, !!x)
}

example_fun(dm, AGE == 64)

try(example_fun(dm, USUBJID))

epijim/admiral documentation built on Feb. 13, 2022, 12:15 a.m.