Skip to contents

[Stable]

Formats a fraction together with ratio in percent with fixed single decimal place. Includes trailing zero in case of whole number percentages to always keep one decimal place.

Usage

format_fraction_fixed_dp(x, ...)

Arguments

x

(named integer)
vector with elements num and denom.

...

not used. Required for rtables interface.

Value

A string in the format num / denom (ratio %). If num is 0, the format is num / denom.

Examples

format_fraction_fixed_dp(x = c(num = 1L, denom = 2L))
#> [1] "1/2 (50.0%)"
format_fraction_fixed_dp(x = c(num = 1L, denom = 4L))
#> [1] "1/4 (25.0%)"
format_fraction_fixed_dp(x = c(num = 0L, denom = 3L))
#> [1] "0/3"