number | R Documentation |
number
is a generic formatter for numeric values.
en
is a shortcut for English format (comma as separator for thousands, point for decimal), fr
for French format (space for thousands, comma for decimal).
percent
a shortcut for English percentages (value are multiplied by 100 and a % symbol is added) and pourcent
a shortcut for French percentages.
comp_percent
returns the complement of 1, i.e. percent(1 - x)
. comp_pourcent
is the French version.
*_format
functions will return another functions, useful to be used for example with ggplot2
.
en0
to en5
are shortcuts for en
with 0 to 5 digits after decimal point. Similarly, fr0
to fr5
are shortcuts of fr
,
percent0
to percent5
of percent
, etc.
number(
x,
accuracy = NULL,
scale = 1,
prefix = "",
suffix = "",
big.mark = " ",
decimal.mark = ".",
style_positive = c("none", "plus"),
style_negative = c("hyphen", "minus", "parens"),
scale_cut = NULL,
trim = TRUE,
...
)
label_number(
accuracy = NULL,
scale = 1,
prefix = "",
suffix = "",
big.mark = " ",
decimal.mark = ".",
style_positive = c("none", "plus"),
style_negative = c("hyphen", "minus", "parens"),
scale_cut = NULL,
trim = TRUE,
...
)
label_en(
accuracy = 1,
scale = 1,
prefix = "",
suffix = "",
big.mark = ",",
decimal.mark = ".",
trim = TRUE,
...
)
en(
x,
accuracy = 1,
scale = 1,
prefix = "",
suffix = "",
big.mark = ",",
decimal.mark = ".",
trim = TRUE,
...
)
label_fr(
accuracy = 1,
scale = 1,
prefix = "",
suffix = "",
big.mark = " ",
decimal.mark = ",",
trim = TRUE,
...
)
fr(
x,
accuracy = 1,
scale = 1,
prefix = "",
suffix = "",
big.mark = " ",
decimal.mark = ",",
trim = TRUE,
...
)
label_percent(
accuracy = NULL,
scale = 100,
prefix = "",
suffix = "%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE,
...
)
percent(
x,
accuracy = NULL,
scale = 100,
prefix = "",
suffix = "%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE,
...
)
label_pourcent(
accuracy = 1,
scale = 100,
prefix = "",
suffix = " %",
big.mark = " ",
decimal.mark = ",",
trim = TRUE,
...
)
pourcent(
x,
accuracy = 1,
scale = 100,
prefix = "",
suffix = " %",
big.mark = " ",
decimal.mark = ",",
trim = TRUE,
...
)
comp_label_percent(
accuracy = 1,
scale = 100,
prefix = "",
suffix = "%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE,
...
)
comp_percent(
x,
accuracy = 1,
scale = 100,
prefix = "",
suffix = "%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE,
...
)
comp_label_pourcent(
accuracy = 1,
scale = 100,
prefix = "",
suffix = " %",
big.mark = " ",
decimal.mark = ",",
trim = TRUE,
...
)
comp_pourcent(
x,
accuracy = 1,
scale = 100,
prefix = "",
suffix = " %",
big.mark = " ",
decimal.mark = ",",
trim = TRUE,
...
)
en0(x)
en1(x)
en2(x)
en3(x)
en4(x)
en5(x)
fr0(x)
fr1(x)
fr2(x)
fr3(x)
fr4(x)
fr5(x)
percent0(x)
percent1(x)
percent2(x)
percent3(x)
percent4(x)
percent5(x)
pourcent0(x)
pourcent1(x)
pourcent2(x)
pourcent3(x)
pourcent4(x)
pourcent5(x)
comp_percent0(x)
comp_percent1(x)
comp_percent2(x)
comp_percent3(x)
comp_percent4(x)
comp_percent5(x)
comp_pourcent0(x)
comp_pourcent1(x)
comp_pourcent2(x)
comp_pourcent3(x)
comp_pourcent4(x)
comp_pourcent5(x)
x |
a numeric vector to format |
accuracy |
A number to round to. Use (e.g.) Applied to rescaled data. |
scale |
A scaling factor: |
prefix |
Additional text to display before the number. The suffix is
applied to absolute value before |
suffix |
Additional text to display after the number. |
big.mark |
Character used between every 3 digits to separate thousands. |
decimal.mark |
The character to be used to indicate the numeric decimal point. |
style_positive |
A string that determines the style of positive numbers:
|
style_negative |
A string that determines the style of negative numbers:
|
scale_cut |
Named numeric vector that allows you to rescale large (or small) numbers and add a prefix. Built-in helpers include:
If you supply a vector |
trim |
Logical, if |
... |
Other arguments passed on to |
a formatted character vector or, for label_*
functions, a function with single parameter x
, a numeric vector, that
returns a character vector
v <- c(12.3, 4, 12345.789, 0.0002)
number(v)
en(v)
fr(v)
en2(v)
en(v, accuracy = .001)
en(v, accuracy = .5)
p <- runif(10)
p
percent(p)
percent2(p)
pourcent2(p)
comp_percent(p)
# Per mille
per_mille <- label_number(scale = 1000, suffix = "\u2030", accuracy = .1)
per_mille(v)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.