pretty_round_p_value: Pretty round p-value

View source: R/pretty_round_p_value.R

pretty_round_p_valueR Documentation

Pretty round p-value

Description

Round p-values to the desired number of decimals and remove leading 0s before the decimal.

Usage

pretty_round_p_value(
  p_value_vector = NULL,
  round_digits_after_decimal = 3,
  include_p_equals = FALSE
)

Arguments

p_value_vector

one number or a numeric vector

round_digits_after_decimal

how many digits after the decimal point should the p-value be rounded to?

include_p_equals

if TRUE, output will be a string of mathematical expression including "p", e.g., "p < .01" (default = FALSE)

Value

the output will be a character vector with p values, e.g., a vector of strings like "< .001" (or "p < .001").

Examples

pretty_round_p_value(0.00001)
pretty_round_p_value(0.00001, round_digits_after_decimal = 4)
pretty_round_p_value(0.00001, round_digits_after_decimal = 5)
# WARNING: the line of code below adding precision that may be unwarranted
pretty_round_p_value(0.00001, round_digits_after_decimal = 6)
pretty_round_p_value(
  p_value_vector = 0.049,
  round_digits_after_decimal = 2, include_p_equals = FALSE)
pretty_round_p_value(c(0.0015, 0.0014, 0.0009), include_p_equals = TRUE)

jinkim3/kim documentation built on Feb. 26, 2025, 10:03 a.m.