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.
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 columnsest,loandhi:"0.80 (95% CI 0.46 to 1.16)".p, of the columnp:"p < 0.001"or"p = 0.047".effect, of the columnsest,lo,hi,pand an optionalunit:"(0.80 points, 95% CI 0.46 to 1.16, p < 0.001)".n_pct, of the columnsnandtotal:"1,037 (68.7%)".mean_sd, of the columnsmeanandsd:"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.
See also
Other blocks:
block(),
check_blocks(),
make_blocks(),
read_blocks(),
txt(),
write_blocks()
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%)"