process_set_values_to {admiraldev}R Documentation

Process set_values_to Argument

Description

The function creates the variables specified by the set_values_to argument, catches errors, provides user friendly error messages, and optionally checks the type of the created variables.

Usage

process_set_values_to(dataset, set_values_to = NULL, expected_types = NULL)

Arguments

dataset

Input dataset

set_values_to

Variables to set

A named list returned by exprs() defining the variables to be set, e.g. exprs(PARAMCD = "OS", PARAM = "Overall Survival") is expected. The values must be symbols, character strings, numeric values, expressions, or NA.

expected_types

If the argument is specified, the specified variables are checked whether the specified type matches the type of the variables created by set_values_to.

Permitted Values: A character vector with values "numeric" or "character"

Value

The input dataset with the variables specified by set_values_to added/updated

Examples

library(dplyr)
data <- tribble(
  ~AVAL,
  20
)

try(
  process_set_values_to(
    data,
    set_values_to = exprs(
      PARAMCD = BMI
    )
  )
)

try(
  process_set_values_to(
    data,
    set_values_to = exprs(
      PARAMCD = 42
    ),
    expected_types = c(PARAMCD = "character")
  )
)

[Package admiraldev version 1.1.0 Index]