convert_num2percent: Convert number vector to percents

View source: R/convert.R

convert_num2percentR Documentation

Convert number vector to percents

Description

convert_num2percent will convert all numbers into percent values with a defined precision. As an alternative, percent or label_percent can be used.

Usage

convert_num2percent(x, digits = 2, format = "f", suffix = "%", ...)

Arguments

x

Integer vector.

digits

Integer for rounding precision.

format

Character vector ('f' or 'g') passed to formatC.

suffix

Character value to append to the end of the number (default is '%').

...

Additional parameters passed to formatC.

Value

Character vector.

Author(s)

Richie Cotton.

Source

Implemented from Richie Cotton's StackOverflow contribution: https://stackoverflow.com/questions/7145826/how-to-format-a-number-as-percentage-in-r

See Also

percent label_percent (e.g. label_percent()(x))

Examples

x <- c(-1, 0, 0.1, 0.5667, 1, 100.2)
convert_num2percent(x)


al-obrien/farrago documentation built on April 14, 2023, 6:20 p.m.