assert_vars: Is an Argument a List of Variables?

Description Usage Arguments Value Author(s) Examples

View source: R/assertions.R

Description

Checks if an argument is a valid list of variables created using vars()

Usage

1
assert_vars(arg, optional = FALSE)

Arguments

arg

A function argument to be checked

optional

Is the checked parameter optional? If set to FALSE and arg is NULL then an error is thrown

Value

The function throws an error if arg is not a list of variables created using vars() and returns the input invisibly otherwise.

Author(s)

Samia Kabi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
example_fun <- function(by_vars) {
  assert_vars(by_vars)
}

example_fun(vars(USUBJID, PARAMCD))

try(example_fun(exprs(USUBJID, PARAMCD)))

try(example_fun(c("USUBJID", "PARAMCD", "VISIT")))

try(example_fun(vars(USUBJID, toupper(PARAMCD), desc(AVAL))))

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