Skip to contents

This function provides a convenient way to apply human readable labels to ggplot2 plots, by first registering them using nn_register and then applying them using this function.

Usage

labs_nn(dict = "default")

Arguments

dict

The dictionary name to use for nickname lookups (optional).

Details

This makes it easy to specify nice names once and use them across a project.

See also

labs_map for direct remapping

Examples

library(ggplot2)

# Register nicknames
nn_register(c(
  "mpg" = "Miles per Gallon",
  "hp" = "Horsepower",
  "factor(cyl)" = "Number of\nCylinders"
))

# Create plot and apply nickname labels
ggplot(mtcars, aes(x = mpg, y = hp, color = factor(cyl))) +
  geom_point() +
  labs_nn()