makePct: Create percentage from share

View source: R/06_formattingFigures.R

makePctR Documentation

Create percentage from share

Description

Make a nice-looking percentage out of a share.

Usage

makePct(x, digits = 0, percSymbol = TRUE, keepTrailing0 = TRUE)

Arguments

x

numeric: a share

digits

integer: number of decimal places for the percentage

percSymbol

logical: return the "%" symbol?

keepTrailing0

logical: keep trailing zeros (decimals) to have the same length for all numbers?

Value

Character

Examples

makePct(0.25)
makePct(1.251, percSymbol = FALSE)
makePct(0.005, digits = 2)
makePct(0.26, digits = 2, keepTrailing0 = FALSE)
makePct(0.26, digits = 2, keepTrailing0 = TRUE)

INWT/INWTUtils documentation built on May 22, 2024, 4:45 p.m.