as.percent | R Documentation |
Format numeric values as character strings with (optional) trailing percent sign.
as.percent(x, digits = 2, big.value = 1, percentSign = TRUE, sep = " ")
x |
vector of numeric values, typically in the range 0..'big.value' |
digits |
desired number of significant digits after the decimal point |
big.value |
largest expected value. All values get scaled so that 'big.value' would be returned as '100 %' |
percentSign |
logical, should the trailing percent sign be appended |
sep |
character string to insert between the numeric percentage and the percent sign. |
Used to represent arbitrary values as a percentage in character format, where the value to be represented as 100 % is given as 'big.value'. Implemented via 'formatC'.
A character vector of the same length as 'x', scaled such that 'big.value' equals 100, with 'digits' significant digits and a trailing ' %' appended.
as.percent( c( 7,21, 4), big.value=30, digits=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.