Formats p-value in line with APA standard, returning it without leading 0 and as < .001 (or below the smallest value expressible with the given number of significant digits) and > .99 when it is extremely small or large.

fmt_p(p_value, digits = 3, equal_sign = TRUE)

Arguments

p_value

Numeric, or a vector of numbers

digits

Number of significant digits, defaults to 3

equal_sign

Logical. Should p-values be prefixed with = unless they are reported as < Defaults to TRUE, for use in text that reports result, FALSE is particularly useful for tables.

Details

Respects the timesaveR.round_method option for consistent rounding behavior (see round_() for details).

Examples

fmt_p(0.04355)
#> [1] "= .044"
fmt_p(0.0001)
#> [1] "< .001"
fmt_p(c(0.04355, 0.0001, 0.654), equal_sign = FALSE)
#> [1] ".044"   "< .001" ".654"