View source: R/label-ordinal.R
label_ordinal | R Documentation |
Round values to integers and then display as ordinal values (e.g. 1st, 2nd, 3rd). Built-in rules are provided for English, French, and Spanish.
label_ordinal(
prefix = "",
suffix = "",
big.mark = " ",
rules = ordinal_english(),
...
)
ordinal_english()
ordinal_french(gender = c("masculin", "feminin"), plural = FALSE)
ordinal_spanish()
prefix , suffix |
Symbols to display before and after value. |
big.mark |
Character used between every 3 digits to separate thousands. |
rules |
Named list of regular expressions, matched in order. Name gives suffix, and value specifies which numbers to match. |
... |
Arguments passed on to
|
gender |
Masculin or feminin gender for French ordinal. |
plural |
Plural or singular for French ordinal. |
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.
Other labels for continuous scales:
label_bytes()
,
label_currency()
,
label_number_auto()
,
label_number_si()
,
label_parse()
,
label_percent()
,
label_pvalue()
,
label_scientific()
demo_continuous(c(1, 5))
demo_continuous(c(1, 5), labels = label_ordinal())
demo_continuous(c(1, 5), labels = label_ordinal(rules = ordinal_french()))
# The rules are just a set of regular expressions that are applied in turn
ordinal_french()
ordinal_english()
# Note that ordinal rounds values, so you may need to adjust the breaks too
demo_continuous(c(1, 10))
demo_continuous(c(1, 10), labels = label_ordinal())
demo_continuous(c(1, 10),
labels = label_ordinal(),
breaks = breaks_width(2)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.