Skip to contents

Use this function to create a "vector" of levels. The vector is actually comprised of a data frame with a column labels and other columns with corresponding level attribute (if any). This data frame can be accessed with lvl_data().

Usage

lvl_attrs(
  levels = NULL,
  labels = NULL,
  prefix = "",
  suffix = "",
  sep = edibble_labels_opt("sep"),
  include_leading_zero = edibble_labels_opt("leading_zero"),
  data = NULL,
  ...
)

Arguments

levels

A vector that either denotes the index number or short name of the levels.

labels

An optional character vector that is the long name format of levels.

prefix

The prefix of the labels.

suffix

The suffix of the labels.

sep

A string to add between prefix and levels.

include_leading_zero

A logical value to indicate whether there should be a leading zero added to level indexes. This is ignored if levels is not numeric.

data

A list or data frame of the same size as the levels.

...

Name-value pair denoting other level attributes. The value should be the same length as levels or a single value.

Value

An edbl_lvls object.

Examples

lvl_attrs(c("A", "B"))
#> <edbl_lvls[2]>
#> [1] A B