Style percentages to be displayed in tables or text

style_percent(x, symbol = FALSE)

Arguments

x

numeric vector of percentages

symbol

Logical indicator to include percent symbol in output. Default is FALSE.

Value

A character vector of styled percentages

See also

See Table Gallery vignette for example

Other style tools: style_pvalue(), style_ratio(), style_sigfig()

Author

Daniel D. Sjoberg

Examples

percent_vals <- c(-1, 0, 0.0001, 0.005, 0.01, 0.10, 0.45356, 0.99, 1.45) style_percent(percent_vals)
#> [1] NA "0" "<0.1" "0.5" "1.0" "10" "45" "99" "145"
style_percent(percent_vals, symbol = TRUE)
#> [1] NA "0%" "<0.1%" "0.5%" "1.0%" "10%" "45%" "99%" "145%"