This function is intended for formatting p-values. Scientific notation is written with LaTeX commands.
FormatPval(x, digits = max(1, getOption("digits") - 2),
eps = .Machine$double.eps, na.form = "NA", scientific = NA)
'numeric'. Vector of p-values.
'integer'. Number of significant digits to be used.
'numeric'.
Numerical tolerance;
values less than eps
are formatted as "< [eps]"
.
'character'. Value used for missing values.
'logical'. Indicates whether values should be encoded in scientific format. A missing value lets R decide whether fixed or scientific notation is used.
A 'character' vector of formatted p-values.
# NOT RUN {
x <- c(stats::runif(5), pi^-100, NA)
FormatPval(x)
format.pval(x)
x <- c(0.1, 0.0001, 1e-27)
FormatPval(x, scientific = TRUE)
FormatPval(x, digits = 3L, eps = 0.001)
# }
Run the code above in your browser using DataLab