Skip to contents

[Experimental]

Help function to format the count and percent into one string.

Usage

h_fmt_count_perc(cnt, perc = NULL, format, ...)

Arguments

cnt

(numeric)
numeric vector for count.

perc

(numeric)
numeric vector for percent, if Null only format count.

format

(string)
formatting string from formatters::list_valid_format_labels() for formatters::format_value() function.

...

other arguments to be passed to formatters::format_value.

Value

A character vector of formatted counts and percents.

Examples

h_fmt_count_perc(cnt = c(5, 9, 12, 110, 0), format = "xx")
#> [1] "5"   "9"   "12"  "110" "0"  
h_fmt_count_perc(
  cnt = c(5, 9, 12, 110, 0),
  perc = c(0.0368, 0.0662, 0.0882, 0.8088, 0),
  format = "xx (xx.x%)"
)
#> [1] "5 (3.7%)"    "9 (6.6%)"    "12 (8.8%)"   "110 (80.9%)" "0 (0.0%)"