Formats numbers as percentages.

num_percent(x, digits = 2L, format = "f", ...)

parse_percent(x, digits = NA, format = "f", ...)

Arguments

x

a numeric vector.

digits

an integer to indicate the number of digits of the percentage string.

format

format type passed to formatC().

...

additional parameters passed to formattable().

See also

Other numeric vectors: num_accounting(), num_comma(), num_currency(), num_digits(), num_scientific()

Examples

num_percent(rnorm(10, 0, 0.1))
#>  [1] 4.29%   -5.04%  -5.10%  0.46%   -8.28%  -6.22%  -11.56% -16.47% -0.28% 
#> [10] -5.79% 
num_percent(rnorm(10, 0, 0.1), digits = 0)
#>  [1] -6%  8%   5%   -2%  -17% 7%   -1%  0%   -3%  -17%
parse_percent("0.5%")
#> [1] 0.5%
parse_percent(c("15.5%", "25.12%", "73.5"))
#> [1] 15.50%   25.12%   7350.00%