Skip to contents

Sometimes want to plot p-values (e.g., volcano plot or MA-plot), but if a statistical test returns a zero p-value, this causes problems with visualization on the log scale. This function returns a vector where the zero values are equal to the smallest nonzero value in the vector.

Usage

lowestnonzero(x)

Arguments

x

A vector of p-values between 0 and 1.

Value

A vector of p-values where zero values are exchanged for the lowest non-zero p-value in the original vector.

Examples

lowestnonzero(c(.042, .02, 0, .001, 0, .89))
#> [1] 0.042 0.020 0.001 0.001 0.001 0.890