count_fraction {junco}R Documentation

Formatting count and fraction values

Description

Formats a count together with fraction (and/or denominator) with special consideration when count is 0, or fraction is 1.
See also: tern::format_count_fraction_fixed_dp()

Usage

jjcsformat_count_fraction(x, d = 1, roundmethod = c("sas", "iec"), ...)

Arguments

x

numeric
with elements num and fraction or num, denom and fraction.

d

numeric(1). Number of digits to round fraction to (default=1)

roundmethod

(string)
choice of rounding methods. Options are:

  • sas: the underlying rounding method is tidytlg::roundSAS, where
    roundSAS comes from this Stack Overflow post https://stackoverflow.com/questions/12688717/round-up-from-5

  • iec: the underlying rounding method is round

...

Additional arguments passed to other methods.

Value

A string in the format ⁠count / denom (ratio percent)⁠. If count is 0, the format is 0. If fraction is >0.99, the format is ⁠count / denom (>99.9 percent)⁠

See Also

Other JJCS formats: format_xx_fct(), jjcsformat_pval_fct(), jjcsformat_range_fct()

Examples

jjcsformat_count_fraction(c(7, 0.7))
jjcsformat_count_fraction(c(70000, 0.9999999))
jjcsformat_count_fraction(c(70000, 1))


[Package junco version 0.1.1 Index]