Formatter for p-values, adding a symbol "<" for small p-values.

pvalue_format(accuracy = 0.001, decimal.mark = ".", add_p = FALSE)

pvalue(x, accuracy = 0.001, decimal.mark = ".", add_p = FALSE)

Arguments

accuracy

Number to round to.

decimal.mark

The character to be used to indicate the numeric decimal point.

add_p

Add "p=" before the value?

x

A numeric vector of p-values.

Value

pvalue_format returns a function with single parameter x, a numeric vector, that returns a character vector.

Examples

p <- c(.50, 0.12, .045, .011, .009, .00002, NA) pvalue(p)
#> [1] "0.500" "0.120" "0.045" "0.011" "0.009" "<0.001" "NA"
pvalue(p, accuracy = .01)
#> [1] "0.50" "0.12" "0.04" "0.01" "<0.01" "<0.01" "NA"
pvalue(p, add_p = TRUE)
#> [1] "p=0.500" "p=0.120" "p=0.045" "p=0.011" "p=0.009" "p<0.001" "p=NA"
custom_function <- pvalue_format(accuracy = .1, decimal.mark = ",") custom_function(p)
#> [1] "0,5" "0,1" "<0,1" "<0,1" "<0,1" "<0,1" "NA"