formatPval | R Documentation |
formatPval
returns p-values according to the number of significant
digits:
p-values < break.eps
are written as "< break.eps"
.
p-values >= break.eps
but < break.middle
have 1
significant digit.
p-values >= break.middle
have 2 significant digits.
whereas formatPvalStrict
allows the user to fix the number of digits
after the decimal point. In case of digits = 2
this means:
p-values < 0.01
(10^(-digits
)) are written as "< 0.01"
.
p-values >= 0.01
are rounded to 2 digits after the decimal
point.
formatPval(x, break.eps = 1e-04, break.middle = 0.01, na.form = "NA", ...)
formatPvalStrict(x, digits = 2L, na.form = "NA", ...)
x |
Numeric vector of p-values. |
break.eps |
Numeric vector of length 1. |
break.middle |
Numeric vector of length 1. |
na.form |
Character representation of |
... |
Additional arguments passed to |
digits |
Numeric vector of length 1 or |
formatPval
internally uses format
whereas
formatPvalStrict
uses formatC
.
A vector of length(x)
with formatted p-values.
Sina Rueeger, Sebastian Meyer, and Felix Hofmann
the base function format.pval
,
format.pval
in package Hmisc,
formatPval
in package reporttools,
formatPval
in package surveillance
x <- c(1e-8, 0.00568, 0.0345, 0.885)
biostatUZH::formatPval(x) # "< 0.0001" "0.006" "0.035" "0.89"
biostatUZH::formatPvalStrict(x, digits = 2) # "< 0.01" "< 0.01" "0.03" "0.89"
## compare to formatting of other packages
if (requireNamespace("reporttools")) {
reporttools::formatPval(x) # "< 0.0001" "0.0057" "0.03" "0.88"
}
if (requireNamespace("Hmisc")) {
Hmisc::format.pval(x) # "0" "0.00568" "0.03450" "0.88500"
}
if (requireNamespace("surveillance")) {
surveillance::formatPval(x) # "<0.0001" "0.0057" "0.035" "0.89"
}
## adapt break.middle
biostatUZH::formatPval(x, break.middle = 0.001)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.