| npercent | R Documentation |
neat representation of percentage
npercent(
percent,
is_ratio = TRUE,
digits = 1,
show_plus_sign = TRUE,
show_growth_factor = FALSE,
show_bps = FALSE,
is_decimal = NULL,
plus_sign = NULL,
factor_out = NULL,
basis_points_out = NULL
)
percent |
an integer or double representing percentage |
is_ratio |
a Boolean variable. If the percent is raw, the value to set as TRUE. See examples below. If the percent variable is already pre-multiplied by 100 then the value to be set as FALSE. |
digits |
number of digits to round-off |
show_plus_sign |
a Boolean variable. If the percent is positive then setting show_plus_sign = TRUE, includes an explicit + sign before the percent |
show_growth_factor |
an optional Boolean variable. |
show_bps |
an optional parameter to get the percentage as basis points If the percent exceeds |100 readable factors. See examples below. |
is_decimal |
Deprecated. Use 'is_ratio' instead. |
plus_sign |
Deprecated. Use 'show_plus_sign' instead. |
factor_out |
Deprecated. Use 'show_growth_factor' instead. |
basis_points_out |
Deprecated. Use 'show_bps' instead. |
String representation of the percentages.
# Formatting 22.3%
npercent(0.223, is_ratio = TRUE, digits = 1)
npercent(22.3, is_ratio = FALSE, digits = 1)
# Formatting percentages with growth factors
npercent(c(-4.01, 2.56), is_ratio = TRUE, show_growth_factor = TRUE)
# Formatting percentages as basis points
npercent(
c(-1, -0.5, -0.1, -0.01, 0, 0.01, 0.1, 0.5, 1),
is_ratio = TRUE, show_bps = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.