View source: R/fmt_pct_special.R
fmt_pct_special | R Documentation |
This function formats numeric vectors with values between 0 and 1 into percentage strings with special specifications. Those specifications are:
0 and 1 are converted to "0%" and "100%" respectively (takes machine precision into account)
all other values < 0.01 are converted to "<1%"
all other values between 0.01 and 0.995 are rounded to percentages without decimals
values between 0.995 and 0.999 are rounded to percentages with 1 decimal
values between 0.999 and 1 are converted to ">99.9%" unless closer to 1 than machine precision.
fmt_pct_special(x)
x |
A vector of numerical values |
A character vector
x <- c(0, 0.004, 0.009, 0.011, 0.9, 0.98, 0.994,
.995, .9989, .999, .9991, .99999999)
fmt <- fmt_pct_special(x)
data.frame(x = x, fmt = fmt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.