Formats numbers as percentages.
num_percent(x, digits = 2L, format = "f", ...)
parse_percent(x, digits = NA, format = "f", ...)
a numeric vector.
an integer to indicate the number of digits of the percentage string.
format type passed to formatC()
.
additional parameters passed to formattable()
.
Other numeric vectors:
num_accounting()
,
num_comma()
,
num_currency()
,
num_digits()
,
num_scientific()
num_percent(rnorm(10, 0, 0.1))
#> [1] -3.31% 7.29% 15.26% 7.18% 0.94% 7.13% 17.14% 0.54% -4.81% 13.61%
num_percent(rnorm(10, 0, 0.1), digits = 0)
#> [1] 11% -5% 6% -8% 8% -10% -2% 16% -11% -5%
parse_percent("0.5%")
#> [1] 0.5%
parse_percent(c("15.5%", "25.12%", "73.5"))
#> [1] 15.50% 25.12% 7350.00%