Description Usage Arguments Value Examples
This function maps over a vector of labels, such as those returned by base::cut
. It works well in formatting ggplot
scales, and can optionally pass parameters to an underlying call to base::formatC
. Any NA
values will be retained.
1 2 3 4 5 6 7 8 9 |
x |
A character vector. |
format |
A function for formatting text, a string giving desired output format, or |
custom |
Logical, whether to use custom formatting, triggering a call to |
mult_by |
A number by which to multiply values in breaks. Defaults to 1, i.e. just the numbers input. Note that multiplication is carried out before rounding and formatting. |
round_digits |
If not |
sep |
A string by which to separate values in breaks. |
... |
Any additional arguments to pass on to the function given in |
A character vector of formatted break labels.
1 2 3 4 5 6 7 | percentage_brks <- c("[0.04,0.15]", "(0.15,0.25]", "(0.25,0.4]")
brk_labels(percentage_brks)
brk_labels(percentage_brks, format = "percent", mult_by = 100)
scientific_brks <- c("[-15500,0]", "(0,20000]", "(20000,25000]")
brk_labels(scientific_brks, format = "e", custom = TRUE, digits = 2)
brk_labels(scientific_brks, format = stringr::str_pad, side = "left", pad = "0", width = 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.