View source: R/label-compose.R
compose_label | R Documentation |
This labeller provides a general mechanism for composing two or more labellers together.
compose_label(..., call = caller_env())
... |
One or more labelling functions. These will be applied to breaks consecutively. Lambda syntax is allowed. |
call |
A call to display in error messages. |
All label_()
functions return a "labelling" function, i.e. a function that
takes a vector x
and returns a character vector of length(x)
giving a
label for each input value.
Labelling functions are designed to be used with the labels
argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
demo_continuous(
c(-100, 100),
labels = compose_label(abs, number, ~paste0(.x, " foobar"), toupper)
)
# Same result
demo_continuous(
c(-100, 100),
labels = compose_label(abs, label_number(suffix = " FOOBAR"))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.