assert_symbol: Is an Argument a Symbol?

Description Usage Arguments Value Author(s) Examples

View source: R/assertions.R

Description

Checks if an argument is a symbol

Usage

1
assert_symbol(arg, optional = FALSE)

Arguments

arg

A function argument to be checked. Must be a quosure. See examples.

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 symbol and returns the input invisibly otherwise.

Author(s)

Thomas Neitmann

Examples

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

example_fun <- function(dat, var) {
  var <- assert_symbol(rlang::enquo(var))
  dplyr::select(dat, !!var)
}

example_fun(dm, USUBJID)

try(example_fun(dm))

try(example_fun(dm, "USUBJID"))

try(example_fun(dm, toupper(PARAMCD)))

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