pretty_percentage: Calculate a percentage, and then format for publication

Description Usage Arguments Value See Also Examples

Description

Take numeric vectors of numerators, and demoninators, round them, format them with trailing zeros, and return as a character string along with the original numeric values.'

Usage

1
2
pretty_percentage(num, denom, digits = 2, percent_scaling = 100,
  as_per = TRUE, ...)

Arguments

num

A numeric or character vector coercible to a numeric vector. Empty character vectors will be returned by the function.

denom

A numeric vector

digits

Integer indicating the number of decimal places to be used.

percent_scaling

A numeric vector indicating the scaling used, by default this is 100 as this gives a percentage.

as_per

Logical indicating if the percentage should be deliminated by a % symbol.

...

Pass additional arguements to format.

Value

A character vector or string, with a percentage and the numerator and denominator used to calculate it

See Also

pretty_round pretty_ci

Examples

1
2
3
4
5
6
7
8
## Return a percentage
pretty_percentage(10, 500)

## Return a vector of percentages
pretty_percentage(c(1,4,6, 19), 100, digits = 1)

## Return a proportion
pretty_percentage(c(1, 2, 4, 5, 2), c(100, 40, 50, 40, 30), as_per = FALSE)

seabbs/prettypublisher documentation built on May 30, 2019, 10:36 p.m.