Skip to contents

Common display rules used by tables, text and plot annotations. No numerical inference is performed.

Usage

format_estimate(x, digits = 3L, decimal_mark = ".", missing = "unavailable")
format_interval(low, high, digits = 3L, decimal_mark = ".")
format_p(x, digits = 3L, decimal_mark = ".", prefix = TRUE)

Arguments

x

Numeric values; p-values must be NA or in [0,1].

digits

An integer from 1 to 15. Significant digits for estimates; decimal places and threshold for p-values.

decimal_mark

Either "." or ","; presentation only.

missing

Display for missing estimates.

low, high

Equally sized stored interval endpoints. Infinities are retained.

prefix

Include p = or p < when TRUE.

Value

A character vector.

Details

P-values below 10^-digits, including stored zero, display a strict upper threshold. Missing p-values never display as nonsignificant. A stored zero may represent numerical underflow, and is not labeled as a mathematically zero probability. Intervals are formatted without calculation or changes of scale.

Examples

format_p(c(0.03, 1e-20, 0, NA_real_))
#> [1] "p = 0.030"     "p < 0.001"     "p < 0.001"     "p unavailable"
format_interval(c(-Inf, 0.1), c(2, 0.5))
#> [1] "[-Inf, 2]"  "[0.1, 0.5]"