A function factory that constructs a case_match function. Useful for the labels
argument of ggplot's scale_*_*
functions.
Examples
fruits <- c("apple", "pear", "pear", "banana")
fruit_relabel <- relabeller("pear" ~ "orange", "banana" ~ "plum")
fruit_relabel(fruits)
#> [1] "apple" "orange" "orange" "plum"
## Normal use case
if (FALSE) { # \dontrun{
ggplot(palmerpenguins::penguins, aes(x = sex, y = flipper_length_mm)) +
geom_point(alpha = 0.5) +
scale_x_discrete(labels = relabeller("male" ~ "BOY\nPENGUIN", "female" ~ "GIRL\nPENGUIN"))
} # }