Skip to contents

This function formats a p-value to a standardized number of significant digits. If the p-value is smaller than the threshold (10^(-sig_digits)), it is returned as "<0.001" (or another appropriate threshold based on sig_digits), otherwise, it is rounded to the specified number of significant digits.

Usage

describe_p_value(value, sig_digits = 3)

Arguments

value

A numeric value representing the p-value to be formatted.

sig_digits

An integer specifying the number of significant digits to retain. Default is 3.

Value

A character string representing the formatted p-value.

Details

The function takes a p-value and checks if it is smaller than a certain threshold determined by the sig_digits parameter. If the p-value is smaller than this threshold, it returns a string indicating that the value is smaller than the threshold. Otherwise, the p-value is returned rounded to the specified number of significant digits.

Examples

describe_p_value(0.0005) # "<0.001"
#> [1] "<0.001"
describe_p_value(0.12345) # "0.123"
#> [1] 0.123
describe_p_value(0.0001, 4) # "<0.0001"
#> [1] 1e-04