as_categorical.decorated: Coerce decorated to Categorical

View source: R/as_categorical.R

as_categorical.decoratedR Documentation

Coerce decorated to Categorical

Description

Coerces (elements of) 'decorated' to categorical. See example(s). Briefly, a continuous variable with units (and a small set of existing values) is converted to a factor-ready variable.

Usage

## S3 method for class 'decorated'
as_categorical(x, ...)

Arguments

x

decorated

...

unquoted names of columns to be converted

Value

decorated

See Also

Other decorated: [.decorated(), [<-.decorated(), [[.decorated(), [[<-.decorated(), as_categorical(), merge.decorated(), names<-.decorated()

Examples

library(magrittr)
library(tablet)
library(kableExtra)
library(yamlet)
x <- data.frame(DOSE = c(12, 1.2, 2.4, 6, 12, 1.2)) %>% decorate('DOSE: [ Dose, mg ]')
x %>% 
  as_categorical(DOSE) %>%
  resolve %>% 
  tablet %>% 
  as_kable %>%
  kable_classic

yamlet documentation built on Jan. 10, 2026, 9:07 a.m.