format_p: Format a p-value according to APA standards

View source: R/print_pvalue.R

format_pR Documentation

Format a p-value according to APA standards

Description

Format a p-value according to APA standards

Usage

format_p(pvalues, decimals = 3, numbers_only = FALSE, latex = TRUE)

Arguments

pvalues

The p-values

decimals

The number of decimals to be printed

numbers_only

Logical, indicates whether the p-values should be printed without the accompanying p. Defaults to FALSE.

latex

Logical, indicates whether the p-values should be printed with or without $ around it. Defaults to TRUE.

Value

A string representation of the p value to be used in Rmarkdown documents.

Examples


# Format a p-value, default is 3 decimals
format_p(0.03123)
format_p(0.000001231)
format_p(0.000001231, decimals = 2)
format_p(0.3123, decimals = 2)
format_p(0.3123, latex = FALSE)
# Format several p-values with one function call
format_p(c(0.3123, 0.001, 0.00001, 0.19))
format_p(c(.999, .9999, 1))
format_p(c(0.3123, 0.001, 0.00001, 0.19, .99999), numbers_only = TRUE)


m-Py/prmisc documentation built on Aug. 23, 2023, 1:20 a.m.