insight (version 0.11.0)

format_p: p-values formatting

Description

Format p-values.

Usage

format_p(
  p,
  stars = FALSE,
  stars_only = FALSE,
  name = "p",
  missing = "",
  digits = 3,
  ...
)

Arguments

p

value or vector of p-values.

stars

Add significance stars (e.g., p < .001***).

stars_only

Return only significance stars.

name

Name prefixing the text. Can be NULL.

missing

Value by which NA values are replaced. By default, an empty string (i.e. "") is returned for NA.

digits

Number of significant digits. May also be "scientific" to return exact p-values in scientific notation, or "apa" to use an APA-style for p-values.

...

Arguments from other methods.

Value

A formatted string.

Examples

Run this code
# NOT RUN {
format_p(c(.02, .065, 0, .23))
format_p(c(.02, .065, 0, .23), name = NULL)
format_p(c(.02, .065, 0, .23), stars_only = TRUE)

model <- lm(mpg ~ wt + cyl, data = mtcars)
p <- coef(summary(model))[, 4]
format_p(p, digits = "scientific")
# }

Run the code above in your browser using DataCamp Workspace