View source: R/format_pvalue.R
| format_pvalue | R Documentation |
Formats p-values for clean display in figures and tables. e.g., p = .0231, p<.0001
format_pvalue(p, digits = 4, include_p = FALSE)
p |
A numeric vector of p-values to format. |
digits |
Number of decimal places to round to. Default is 4. |
include_p |
Logical. If TRUE, includes "p" prefix before the formatted value (e.g., "p = .05"). Default is FALSE. |
A character vector of formatted p-values.
# Basic usage
format_pvalue(0.05)
format_pvalue(0.0001)
# More rounding
format_pvalue(0.0001,digits=2)
# Vector input
format_pvalue(c(0.05, 0.001, 0.00001, 0.99))
# With p prefix
format_pvalue(0.05, include_p = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.