pvalr: p-value formatter

View source: R/utils2.R

pvalrR Documentation

p-value formatter

Description

Formats several cases of p-values; see details.

Note that a previous pvalr function had additional arguments. For this version, see rawr2::pvalr.

Usage

pvalr(
  pv,
  sig.limit = 1e-03,
  digits = 2L,
  scientific = FALSE,
  html = FALSE,
  show.p = FALSE,
  ...
)

pvalr2(pv, html = FALSE, show.p = FALSE)

color_pval(
  pv,
  breaks = c(0, 0.01, 0.05, 0.1, 0.5, 1),
  cols = colorRampPalette(2:1)(length(breaks)),
  sig.limit = 1e-03,
  digits = 2L,
  show.p = FALSE,
  format_pval = TRUE,
  na = "-",
  ...
)

Arguments

pv

for pvalr, a numeric value or vector of p-values; for pvalr2, a vector of p-values as character strings

sig.limit

lower bound for precision; smaller values will be shown as < sig.limit

digits

number of significant digits

scientific

see format

html

logical; if TRUE, uses HTML entities for < and >

show.p

logical; if TRUE, inserts p = , p < , or p > where appropriate

...

ignored

breaks, cols

a numeric vector defining breaks in (0,1) (passed to findInterval) and the corresponding colors

format_pval

logical; if TRUE, p-values will be formatted using pvalr; alternatively, a function may by used which will be applied to each p-value

na

a string used for NA p-values (default is "-")

Details

pvalr rounds numeric values to a specified number of significant digits and add (if necessary) trailing 0s. The result will be a character string to prevent loss of significant digits.

Note that negative values are treated as small p-values (similar to format.pval), but unlike format.pval, values greater than 1 are formatted as > 1 - 1 / 10 ^ digits

pvalr2 deals with common cases of character string p-values which are not ideal (0.000, 1.00, etc.) and will leave others unchanged.

See Also

roundr; format.pval; rawr:::signif2

Examples

pv <- c(-1, 0.001, 0.0001, 0.0042, 0.0601, 0.1335, 0.4999, 0.9, 0.997, 1, 2)
format.pval(pv, eps = 0.001)

pvalr(pv)
pvalr(pv, digits = 3)
pvalr(pv, show.p = TRUE, html = TRUE)

## Not run: 
## older version of pvalr in rawr2 package
## note differences in digits used
rawr2::pvalr(pv)
rawr2::pvalr(pv, journal = FALSE)
rawr2::pvalr(pv, limits = 0.1)

## End(Not run)

pv <- c('0.00000', '< 0.001', '0.0', '0.123', '0.6', '1', '1.0', '1.000')
pvalr2(pv)

## Not run: 
pv <- c(0, 0.00001, 0.03, 0.06, 0.11, 0.49, 0.51, 0.89, 0.9, 1)
show_html(color_pval(pv))
show_html(color_pval(pv, format_pval = format.pval))
show_html(iprint(color_pval(pv, show.p = TRUE)))

## End(Not run)


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.