Description Usage Arguments Details Value Examples
formatPval
is intended for formatting p-values, and is based on
the function format.pval
in the base R-package.
1 2 3 | formatPval(pv, digits = max(1, getOption("digits") - 2),
eps = 0.0001, na.form = "NA", scientific = FALSE,
includeEquality=FALSE)
|
pv |
a numeric vector. |
digits |
how many significant digits are to be used. |
eps |
a numerical tolerance: see ‘Details’. |
na.form |
character representation of |
scientific |
use scientific number format (not by default) |
includeEquality |
include equality signs in front of the large p-values? (not by default) |
formatPval
is mainly an auxiliary function for the family of
table functions, but can also be useful on its own. If a p-value is
smaller than eps
, we return just that it is smaller than the
threshold but no longer the exact value. This function is more general
than format.pval
the behaviour of which can (almost) be
obtained by using the options eps = .Machine$double.eps
and
scientific = TRUE
.
A character vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## include equality signs?
formatPval(c(stats::runif(5), pi^-100, NA))
formatPval(c(stats::runif(5), pi^-100, NA), include=TRUE)
## try another eps argument
formatPval(c(0.1, 0.0001, 1e-7))
formatPval(c(0.1, 0.0001, 1e-7), eps=1e-7)
## only the white space can differ with the base function result:
(a <- formatPval(c(0.1, 0.0001, 1e-27),
eps = .Machine$double.eps, scientific = TRUE))
(b <- format.pval(c(0.1, 0.0001, 1e-27)))
all.equal(a, b)
|
Loading required package: xtable
[1] "0.86" "0.16" "0.37" "0.91" "0.72" "< 0.0001" "NA"
[1] "= 0.93" "= 0.43" "= 0.34" "= 0.33" "= 0.28" "< 0.0001" "NA"
[1] "0.10" "0.0001" "< 0.0001"
[1] "0.10" "0.0001" "0.0000001"
[1] "0.10" "0.0001" "< 2e-16"
[1] "1e-01" "1e-04" "<2e-16"
[1] "3 string mismatches"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.