Description Usage Arguments Value Author(s) See Also Examples
Convert a vector, list or matrix of numeric values to percentage values.
1 2 3 |
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%). |
Character in percentage format, as with the same structure with x
.
Yiying Wang, wangy@aetna.com
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.