Numeric vector with percentage representation

percent(x, digits, format = "f", ...)

# Default S3 method
percent(x, digits = 2L, format = "f", ...)

# S3 method for class 'character'
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.

Examples

percent(rnorm(10, 0, 0.1))
#>  [1] 4.25%   -16.84% 2.49%   10.73%  20.39%  4.49%   13.92%  4.27%   1.08%  
#> [10] 0.22%  
percent(rnorm(10, 0, 0.1), digits = 0)
#>  [1] 6%   -3%  -5%  2%   -11% 8%   1%   -13% -9%  5%  
percent("0.5%")
#> [1] 0.5%
percent(c("15.5%", "25.12%", "73.5"))
#> [1] 15.50%   25.12%   7350.00%