Learn R Programming

ggh4x (version 0.2.8)

sep_discrete: Separator for discrete grouped labels

Description

This is a function factory that provides a function to split grouped discrete labels into numerical positions.

Usage

sep_discrete(sep = ".", inv = FALSE)

Value

A function that accepts character input and returns numeric output.

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.

Examples

Run this code
# Here, 'bar.qux' belongs to the second group, so has +1 value
sep_discrete()(c("foo.bar", "bar.bar", "bar.qux"))

# Now, the values are grouped by the groups before the separator
sep_discrete(inv = TRUE)(c("foo.bar", "bar.bar", "bar.qux"))

Run the code above in your browser using DataLab