The labels function creates a vector of labels associated with
a user-defined format.
# S3 method for class 'fmt'
labels(object, ...)A vector of label values.
The condition function creates a condition as part of a format
definition. Each condition has a label as part of its definition.
The labels function extracts the labels from the conditions and
returns them as a vector. While the labels will typically be of type
character, they can be of any data type. See the condition
function help for further details.
value to define a format,
condition to define the conditions for a format, and
fapply to apply the format to a vector.
Other fmt:
as.data.frame.fmt(),
as.fmt(),
as.fmt.data.frame(),
condition(),
is.format(),
print.fmt(),
value()
# Define format
fmt1 <- value(condition(x == "A", "Label A"),
condition(x == "B", "Label B"),
condition(TRUE, "Other"))
#> # A user-defined format: 3 conditions
#> Name Type Expression Label Order
#> 1 x U x == "A" Label A NA
#> 2 x U x == "B" Label B NA
#> 3 x U TRUE Other NA
# Extract labels
labels(fmt1)
#> [1] "Label A" "Label B" "Other"
# [1] "Label A" "Label B" "Other"