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

percent

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%
convNum2Pct(c(0.04, 0.3, NA), digits=1)  # return
# c("4.0%", "30.0%", NA)

convNum2Pct(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/aseshms documentation built on May 21, 2019, 11:03 a.m.