Skip to contents

house_formatters() gives the formatters that txt() uses when the project gives no formatter of the same name. Each formatter takes the raw value of a block, a data.frame, and returns one string for each row.

Usage

house_formatters()

Value

A named list of 5 functions: ci, p, effect, n_pct and mean_sd.

Details

The list holds 5 formatters. Each name is the format of a block(). The examples show the string for one row:

  • ci, of the columns est, lo and hi: "0.80 (95% CI 0.46 to 1.16)".

  • p, of the column p: "p < 0.001" or "p = 0.047".

  • effect, of the columns est, lo, hi, p and an optional unit: "(0.80 points, 95% CI 0.46 to 1.16, p < 0.001)".

  • n_pct, of the columns n and total: "1,037 (68.7%)".

  • mean_sd, of the columns mean and sd: "30.7 (4.8)".

A numeric column digits gives the decimals of each row. The defaults are 2 for ci and effect, and 1 for n_pct and mean_sd. A p-value has 3 decimals. The count of n_pct has no decimals and a comma as the thousands mark.

A negative number starts with the minus sign U+2212. A number that rounds to zero has no sign. A row with an NA in a column that the formatter uses gives NA. A formatter stops when a column that it needs is absent or not numeric. It also stops when a digits value is not a whole number of 0 or more.

Examples

house_formatters()$ci(data.frame(est = 0.8, lo = -0.0712, hi = 1.16))
#> [1] "0.80 (95% CI −0.07 to 1.16)"
house_formatters()$n_pct(data.frame(n = 1037, total = 1509))
#> [1] "1,037 (68.7%)"