as_formatted_p_value: Formatting p values

View source: R/stringr-like.R

as_formatted_p_valueR Documentation

Formatting p values

Description

Vectorised conversion

Usage

as_formatted_p_value(
  x,
  decimal_places = 3,
  prefix = "p",
  less_than_cutoff = 0.001,
  remove_trailing_zeroes = T,
  alpha = 0.05,
  ns_replacement = NULL
)

Arguments

x

Numeric vector

decimal_places

Decimal places to display

prefix

Prefix to prepend (default "p=")

less_than_cutoff

Cut-off for small p values. Values smaller than this will be displayed like "p<..."

remove_trailing_zeroes

If the required decimal places are less than decimal places, should resulting trailing zeros be removed?

alpha

Cut-off for assuming significance, usually 0.05

ns_replacement

If p value is not significant (is > alpha), it will be replace by this string (e.g. "n.s.") If NULL (default), no replacement is performed.

Vectorised (in parallel) over x, prefix, less_than_cutoff, alpha and ns_replacement.

Value

Character vector

Examples

as_formatted_p_value(0.02) # "p=0.02"
as_formatted_p_value(0.00056) # "p<0.001"

tidytidbits documentation built on March 18, 2022, 6:10 p.m.