# Example scale
template <- scale_x_discrete(limits = c("A 1", "B 1", "C&1", "D&2", "E&2"))
# By default, splits on all non-alphanumeric characters
auto <- key_range_auto()
auto(template)
# Only split on a specific character
auto <- key_range_auto(sep = "&")
auto(template)
# Treating the letters as outer labels and numbers as inner labels
auto <- key_range_auto(reverse = TRUE)
auto(template)
# Providing custom values
key_range_manual(
start = c(1, 5, 10),
end = c(4, 15, 11),
level = c(0, 2, 1),
name = c("A", "B", "C")
)
# Values from a
key_range_map(presidential, start = start, end = end, name = name)
Run the code above in your browser using DataLab