p_round {rstatix} | R Documentation |
Rounding and Formatting p-values
Description
Round and format p-values. Can also mark significant p-values with stars.
Usage
p_round(x, ..., digits = 3)
p_format(
x,
...,
new.col = FALSE,
digits = 2,
accuracy = 1e-04,
decimal.mark = ".",
leading.zero = TRUE,
trailing.zero = FALSE,
add.p = FALSE,
space = FALSE
)
p_mark_significant(
x,
...,
new.col = FALSE,
cutpoints = c(0, 1e-04, 0.001, 0.01, 0.05, 1),
symbols = c("****", "***", "**", "*", "")
)
p_detect(data, type = c("all", "p", "p.adj"))
p_names()
p_adj_names()
Arguments
x |
a numeric vector of p-values or a data frame containing a p value
column. If data frame, the p-value column(s) will be automatically detected.
Known p-value column names can be obtained using the functions
|
... |
column names to manipulate in the case where |
digits |
the number of significant digits to be used. |
new.col |
logical, used only when |
accuracy |
number to round to, that is the threshold value above wich the function will replace the pvalue by "<0.0xxx". |
decimal.mark |
the character to be used to indicate the numeric decimal point. |
leading.zero |
logical. If FALSE, remove the leading zero. |
trailing.zero |
logical. If FALSE (default), remove the training extra zero. |
add.p |
logical value. If TRUE, add "p=" before the value. |
space |
logical. If TRUE (default) use space as separator between different elements and symbols. |
cutpoints |
numeric vector used for intervals |
symbols |
character vector, one shorter than cutpoints, used as significance symbols. |
data |
a data frame |
type |
the type of p-value to detect. Can be one of |
Value
a vector or a data frame containing the rounded/formatted p-values.
Functions
-
p_round()
: round p-values -
p_format()
: format p-values. Add a symbol "<" for small p-values. -
p_mark_significant()
: mark p-values with significance levels -
p_detect()
: detects and returns p-value column names in a data frame. -
p_names()
: returns known p-value column names -
p_adj_names()
: returns known adjust p-value column names
Examples
# Round and format a vector of p-values
# ::::::::::::::::::::::::::::::::::::::::::::
# Format
p <- c(0.5678, 0.127, 0.045, 0.011, 0.009, 0.00002, NA)
p_format(p)
# Specify the accuracy
p_format(p, accuracy = 0.01)
# Add p and remove the leading zero
p_format(p, add.p = TRUE, leading.zero = FALSE)
# Remove space before and after "=" or "<".
p_format(p, add.p = TRUE, leading.zero = FALSE, space = FALSE)
# Mark significant p-values
# ::::::::::::::::::::::::::::::::::::::::::::
p_mark_significant(p)
# Round, the mark significant
p %>% p_round(digits = 2) %>% p_mark_significant()
# Format, then mark significant
p %>% p_format(digits = 2) %>% p_mark_significant()
# Perform stat test, format p and mark significant
# ::::::::::::::::::::::::::::::::::::::::::::
ToothGrowth %>%
group_by(dose) %>%
t_test(len ~ supp) %>%
p_format(digits = 2, leading.zero = FALSE) %>%
p_mark_significant()