npercent {neatR}R Documentation

neat representation of percentage

Description

neat representation of percentage

Usage

npercent(
  percent,
  is.decimal = TRUE,
  digits = 1,
  plus.sign = TRUE,
  factor.out = FALSE
)

Arguments

percent

an integer or double representing percentage

is.decimal

a Boolean variable. If the percent is raw, the value to set as TRUE. See examples below. If the percent variable is already pre-multiplied by 100 then the value to be set as FALSE.

digits

number of digits to round-off

plus.sign

a Boolean variable. If the percent is positive then setting plus_sign = TRUE, includes an explicit + sign before the percent

factor.out

an optional Boolean variable. If the percent exceeds |100 readable factors. See examples below.

Value

String representation of the percentages.

Examples

# Formatting 22.3%
npercent(0.223, is.decimal = TRUE, digits = 1)
npercent(22.3, is.decimal = FALSE, digits = 1)
# Formatting percentages with growth factors
npercent(c(-4.01, 2.56), is.decimal = TRUE, factor.out = TRUE)

[Package neatR version 0.2.0 Index]