Skip to contents

Returns p-values in common journal formats:

  • p < 0.001 → "name < 0.001"

  • 0.001 ≤ p < 0.01 → scientific notation (with ×10⁻ⁿ)

  • p ≥ 0.01 → keep 3 decimal places

Outputs as plotmath expressions that can be directly used in ggplot2::annotate() or ggpmisc::stat_poly_eq() label parameters.

Usage

format_p_value(p, name)

Arguments

p

Numeric vector, p-values to format (typically 0-1)

name

Character scalar, p-value prefix, e.g., "p", "P interaction", "P trend"

Value

Character vector, valid \code{plotmath} expressions, e.g.,
        \code{"p < 0.001"}, \code{"p~\"=\"~3.14\times10^{-4}"},
        \code{"p~\"=\"~0.03"}

Examples

format_p_value(0.0001, "p")
#> [1] "p < 0.001"