format_percent: Format a numerical vector as percents

Description Usage Arguments Value Examples

View source: R/Formatting.R

Description

Format a numerical vector as a character vector holding the values formatted as percents. Will throw an error for non-numeric vetcors, and print a message if NA values are found.

Usage

1
format_percent(vec, accuracy = 0.01, vec_names = names(vec), silent = FALSE)

Arguments

vec

Vector to format as a percent.

accuracy

The number to round to the nearest multiple of (e.g 3.14159 will round to 314.16% by default). The absolute value of this parameter will be used. The rounding will be done after conversion to a percent.

vec_names

Vector used to name the output.

silent

If TRUE, will not print out a message if NA values are found.

Value

Character vector of items formatted as percent.

Examples

1
2
3
4
5
format_percent(0.12345)
format_percent(pi)
format_percent(0.1)
format_percent(0.12345, accuracy = 0.1)
format_percent(c(0.12345, 0.54321), vec_names = c("a", "b"))

KO112/KO documentation built on Oct. 2, 2020, 9:21 a.m.