convNum2Pct: Convert numbers to percents

Description Usage Arguments Value Author(s) See Also Examples

Description

Convert a vector, list or matrix of numeric values to percentage values.

Usage

1
2
3
convNum2Pct(x, digits = 0, value_asis = TRUE, ...)

to_pct(x, digits = 0, value_asis = TRUE, ...)

Arguments

x

A numeric vector, list, or matrix.

digits

Digits of the percentage numbers. Default 0.

value_asis

Logical, default TRUE. Whether keep the actual value. If FALSE, the result will keep the numeric part as is (100 times smaller, e.g., 0.5 –> 0.5%).

Value

Character in percentage format, as with the same structure with x.

Author(s)

Yiying Wang, wangy@aetna.com

See Also

number_format

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
## Multiply the numbers with 100 and *100%
to_pct(c(0.04, 0.3, NA), digits=1)  # return
# c("4.0%", "30.0%", NA)

to_Pct(c(0.04, 0.3, NA), digits=1, value_asis=FALSE)  # returns
# c("0.04%", "0.3%", NA)

to_pct(list(0.04, -0.9, list(0.65, NULL)))
[[1]]
[1] "4%"

[[2]]
[1] "-90%"

[[3]]
[[3]][[1]]
[1] "65%"
[[3]][[2]]
NULL

## End(Not run)

madlogos/aseskit documentation built on June 26, 2019, 12:17 a.m.