Skip to contents

Formats a numeric vector of probabilities as percentage strings the way simulation summaries want them: values below 1% render as "<1%" and values above 99.9% as ">99.9%", so a long-shot never reads as a flat 0% and a near-lock never reads as a certain 100%. Exact 0 and exact 1 are left as "0%" and "100%".

Adapted from nflseedR's fmt_pct_special().

Usage

fmt_pct_special(x)

Arguments

x

A numeric vector of probabilities, all between 0 and 1 (NA is allowed and returned as NA).

Value

A character vector the same length as x.

Examples

# \donttest{
fmt_pct_special(c(0, 0.0004, 0.123, 0.5, 0.9994, 1))
#> [1] "0%"     "<1%"    "12%"    "50%"    ">99.9%" "100%"  
# }