formatp {tab} | R Documentation |
Format P-values for Functions in the tab Package
Description
Formats p-values for tables generated by the functions in the tab package. Handles rounding and presentation of p-values.
Usage
formatp(
p,
decimals = c(2, 3),
cuts = 0.01,
lowerbound = 0.001,
leading0 = TRUE,
avoid1 = FALSE
)
Arguments
p |
Numeric vector of p-values. |
decimals |
Number of decimal places for p-values. If a vector is
provided rather than a single value, number of decimal places will depend on
what range the p-value lies in. See |
cuts |
Cut-point(s) to control number of decimal places used for
p-values. For example, by default |
lowerbound |
Controls cut-point at which p-values are no longer printed
as their value, but rather <lowerbound. For example, by default
|
leading0 |
If |
avoid1 |
If |
Value
Character vector.
Examples
# Generate vector of numeric p-values
set.seed(123)
p <- c(runif(n = 5, min = 0, max = 1), 1, 0, 4e-7, 0.009)
# Round to nearest 2 decimals for p in (0.01, 1] and 3 decimals for p < 0.01
pvals <- formatp(p = p)
# Use 2 decimal places, a lower bound of 0.01, and omit the leading 0
pvals <- formatp(p = p, decimals = 2, lowerbound = 0.01, leading0 = FALSE)