percent: Numeric vector with percentage representation

Description Usage Arguments Examples

View source: R/formats.R

Description

Numeric vector with percentage representation

Usage

1
2
3
4
5
6
7
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

1
2
3
4
percent(rnorm(10, 0, 0.1))
percent(rnorm(10, 0, 0.1), digits = 0)
percent("0.5%")
percent(c("15.5%", "25.12%", "73.5"))

Example output

 [1] -8.83%  -14.87% -8.69%  12.59%  -10.38% -13.35% -2.43%  7.29%   1.23%  
[10] -13.12%
 [1] 8%   -12% 4%   9%   -10% -1%  14%  -9%  -6%  -0% 
[1] 0.5%
[1] 15.50%   25.12%   7350.00%

formattable documentation built on Jan. 13, 2021, 7:17 a.m.