Learn R Programming

mcradds (version 1.1.1)

h_fmt_count_perc: Format count and percent

Description

[Experimental]

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

Usage

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

Value

A character vector of formatted counts and percents.

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.

Examples

Run this code
h_fmt_count_perc(cnt = c(5, 9, 12, 110, 0), format = "xx")
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%)"
)

Run the code above in your browser using DataLab