This is a function factory that provides a function to split grouped discrete
labels into numerical positions.
Usage
sep_discrete(sep = ".", inv = FALSE)
Arguments
- sep
A character(1)
separator to use for splitting. May not contain
regular expressions.
- inv
A logical(1)
whether to invert the layering of groups.
Value
A function
that accepts character
input and returns
numeric
output.
Examples
# Here, 'bar.qux' belongs to the second group, so has +1 value
sep_discrete()(c("foo.bar", "bar.bar", "bar.qux"))
#> [1] 1 2 4
# Now, the values are grouped by the groups before the separator
sep_discrete(inv = TRUE)(c("foo.bar", "bar.bar", "bar.qux"))
#> [1] 1 3 4