n_pct: Prints number of observations and its percantage in brackets

View source: R/n_pct.R

n_pctR Documentation

Prints number of observations and its percantage in brackets

Description

This function is especially useful when used in Rmarkdown documents or tables.

Usage

n_pct(x, total, digits = 1, brackets = TRUE, ...)

Arguments

x

Numerator, will also be displayed as n (never prints with trailing zeros.)

total

Denominator

digits

Digits to display after decimal point for percentage only

brackets

Whether percentages should be displayed in bracktes, alternative is seperation with ","

...

additional arguments passed to bernr::comma()

Value

Character object

Examples

n_pct(10, 1000)
# 10.0 (1.0%)

n_pct(10, 1000, trailing = TRUE, brackets = FALSE)
# 10.0, 1.0%

n_pct(10, 1000, trailing = FALSE, brackets = FALSE)
# 10, 1%


bsurial/bernr documentation built on Nov. 7, 2022, 1:41 a.m.