pretty_p | R Documentation |
Format p values for display
pretty_p( p, p_digits, small_p_format = c("<", "E", "x10", "plotmath", "html"), small_p_cutoff = 10^-p_digits, sig_fig = FALSE, n_sig_fig = 2 )
p |
p value to format |
p_digits |
number of digits to display |
small_p_format |
format used to display p values below a threshold |
small_p_cutoff |
cutoff for displaying alternative formatting |
sig_fig |
whether to use significant figures when rounding p values |
n_sig_fig |
number of significant figures to use |
formatted p value
p_values <- 10 ^ seq(-1, -6, -1) # Format p values as for example 1.0x10^-4 pretty_p(p_values, p_digits = 3, small_p_format = "x10") # Format p values for use on a graph x <- rlnorm(100, 3, 1) y <- rlnorm(100, 4, 1) p <- wilcox.test(x, y)$p.value p_formatted <- pretty_p(p, p_digits = 3, small_p_format = "plotmath") boxplot(x, y, ylim = c(0, max(c(x, y)) + 100)) text(1.5, max(c(x, y) + 50), parse(text = paste0("p == ", p_formatted)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.