Format a p-value for APA style

Description

Formats a p-value following APA conventions: values less than .001 are displayed as "< .001", and leading zeros are removed.

Usage

format_p_value(p, digits = 3, include_p = FALSE)

Arguments

p Numeric. The p-value to format.
digits Integer. Number of decimal places. Default is 3.
include_p Logical. If TRUE, prefix with "p = " or "p < ". Default FALSE.

Value

A character string with the formatted p-value.

Examples

[1] ".023"
[1] "< .001"
format_p_value(0.150, include_p = TRUE)
[1] "p = .150"