Learn R Programming

statuser (version 0.1.9)

format_pvalue: Format P-Values for Display

Description

Formats p-values for clean display in figures and tables. e.g., p = .0231, p<.0001

Usage

format_pvalue(p, digits = 4, include_p = FALSE)

Value

A character vector of formatted p-values.

Arguments

p

A numeric vector of p-values to format.

digits

Number of decimal places to round to. Default is 4.

include_p

Logical. If TRUE, includes "p" prefix before the formatted value (e.g., "p = .05"). Default is FALSE.

Examples

Run this code
# Basic usage
format_pvalue(0.05)
format_pvalue(0.0001)

# More rounding
format_pvalue(0.0001,digits=2)

# Vector input
format_pvalue(c(0.05, 0.001, 0.00001, 0.99))

# With p prefix
format_pvalue(0.05, include_p = TRUE)

Run the code above in your browser using DataLab