Description Usage Arguments Format Details Value Examples
View source: R/format_p_value.R
Functions to fromat p values.
NOTE: concider using scales::pvalue()
instead.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | format_p_values(
p,
digits_p = 3,
cols = NULL,
...,
alpha = 0.05,
signif_stars = TRUE,
rm_zero = FALSE,
add_p = FALSE,
rm_spaces = FALSE,
ss = signif_syms
)
## Default S3 method:
format_p_values(
p,
digits_p = 3,
cols = NULL,
...,
signif_stars = TRUE,
rm_zero = FALSE,
add_p = FALSE,
rm_spaces = FALSE,
ss = signif_syms
)
format_p(
p_i,
digits_p = 3,
signif_stars = TRUE,
rm_zero = FALSE,
add_p = FALSE,
rm_spaces = FALSE,
ss = signif_syms
)
## S3 method for class 'data.frame'
format_p_values(
p,
digits_p = 3,
cols = NULL,
...,
ss = signif_syms,
signif_stars = TRUE,
rm_zero = FALSE,
add_p = FALSE,
rm_spaces = FALSE
)
add_signif_stars(p, ss = signif_syms)
get_signif_stars(p, ss = signif_syms)
signif_syms_05s
p05
signif_syms_01s
p01
signif_syms_001s
p001
signif_syms_001
signif_syms_01
signif_syms_05
signif_syms
p05_01_001
p05plus
signif_stars_legend_2(ss = signif_syms)
signif_stars_legend(
ss = signif_syms,
decreasing = FALSE,
collapse = c(" \n", ", ", "; ")
)
rm_zero(str, dec = ".")
format_as_p_columns(
data,
colnames = c("p.value", "p.adjust"),
digits_p = 3,
rm_zero = FALSE,
signif_stars = FALSE,
...
)
|
p |
A (vector of) p-value(s). Numeric or coercible to numeric.
Or a |
digits_p |
(numeric) Number of significant digits to round a p value to. No less than 2.
|
cols, alpha, ss, decreasing, collapse, dec |
|
... |
Arguments to further methods. |
signif_stars |
(logical) Flag if significance stars should be added to each p value. Not less than 2. |
rm_zero |
(logical) Flag if leading zero before the point should be removed. |
add_p |
(logical) Flag if letter "p" should included in the expression. |
rm_spaces |
(logical) Flag if all spaces should be removed. |
An object of class numeric
of length 1.
An object of class numeric
of length 1.
An object of class numeric
of length 1.
An object of class numeric
of length 1.
An object of class numeric
of length 1.
An object of class numeric
of length 1.
An object of class numeric
of length 1.
An object of class numeric
of length 2.
An object of class numeric
of length 3.
An object of class numeric
of length 4.
An object of class numeric
of length 4.
An object of class numeric
of length 4.
format_p
- formats single p value.
format_as_p_columns
- formats indicated numeric columns in a dataframe as p values (columns are converted into strings).
get_signif_stars
- takes numeric p values brings appopriate stars of statistical significance.
add_signif_stars
- formats numeric p values by adding significance stars (result is character vector).
signif_stars_legend
- generates legend for significance stars (result is a string).
rm_zero
- function removes zero at the beginning of a number (returns a string with the same value but without the leading zero).
A character vector with formatted p values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | library(biostat)
# Prettify p-values
format_p_values(0.0005)
format_p_values(0.005)
format_p_values(0.005, signif_stars = FALSE)
format_p_values(0.005, rm_zero = TRUE)
format_p_values(0.005, digits_p = 2)
format_p_values(0.005, digits_p = 2, rm_zero = TRUE, signif_stars = FALSE)
format_p_values(0.00022)
format_p_values("0.00022")
format_p_values("0.052")
format_p_values(c(0.005, 0.0005, 0.052147))
get_signif_stars(0.005)
add_signif_stars(0.005)
get_signif_stars(0.0005)
add_signif_stars(0.0005)
get_signif_stars(0.052147)
add_signif_stars(0.052147)
signif_stars_legend()
format_p(0)
format_p(.02, digits_p = 2)
format_p(.0002)
format_p(.0002, signif_stars = FALSE)
format_p(.0002, ss = c("*****" = 0.001))
# TODO **[!!!]**:
# 1. Add parameter to emable p value correction
# from p = 1 into, e.g., p > 0.999;
#
# 2. merge parameters `ss` and `signif_stars`
# 3. test: format_p(NaN) -- [OK]
# 4. test: format_p(NA) -- this function fails with NA as input.
rm_zero(0.020)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.