set_var_levels {xpose.xtras}R Documentation

Set variable levels

Description

For variable types such as catcov, it can be convenient to define levels. This function provides a straightforward means to do so, consistent with tidy functions like <case_when>.

Several convenience functions are provided for common levels in <levelers>.

Usage

set_var_levels(
  xpdb,
  .problem = NULL,
  ...,
  .missing = "Other",
  .handle_missing = c("quiet", "warn", "error")
)

Arguments

xpdb

<xp_xtras> object

.problem

<numeric> Problem number to use. Uses the all problems if NULL

...

<list> of formulas or leveler functions, where the relevant variable is provided as the argument,

.missing

<character> Value to use for missing levels

.handle_missing

<character> How to handle missing levels: "quiet", "warn", or "error"

Value

<xp_xtras> object with updated levels

Examples


set_var_levels(xpdb_x,
  SEX = lvl_sex(),
  MED1 = lvl_bin(),
  MED2 = c(
    0 ~ "n",
    1 ~ "y"
  )
)


[Package xpose.xtras version 0.0.2 Index]