This function was written to allow easy demonstrations of flextable's ability to produce table summaries (with summarizor()). It assumes that we have either a quantitative variable, in which case we will display the mean and the standard deviation, or a qualitative variable, in which case we will display the count and the percentage corresponding to each modality.

fmt_2stats(
  num1,
  num2,
  cts,
  pcts,
  num1_mask = "%.01f",
  num2_mask = "(%.01f)",
  cts_mask = "%.0f",
  pcts_mask = "(%.02f %%)"
)

Arguments

num1

a numeric statistic to display such as a mean or a median

num2

a numeric statistic to display such as a standard deviation or a median absolute deviation.

cts

a count to display

pcts

a percentage to display

num1_mask

format associated with num1, a format string used by sprintf().

num2_mask

format associated with num2, a format string used by sprintf().

cts_mask

format associated with cts, a format string used by sprintf().

pcts_mask

format associated with pcts, a format string used by sprintf().