Skip to contents

Reads back a label written by [q_label]. The pattern accepted is exactly two integer-percent digits, `x`, then one decimal digit. Any string that does not match returns `NA` rather than erroring.

Usage

q_value(label)

Arguments

label

Character vector of quantile labels, e.g. "q02x5".

Value

Numeric vector of probabilities; `NA` for an unparseable label.

Details

The round trip `q_value(q_label(p))` returns `p` only when `p` is expressible in that format, i.e. a probability on the 0.001 grid below 1. `q_label()` rounds anything finer (`0.0125` becomes `"q01x2"`, which reads back as `0.012`), and `q_label(1)` gives the three-digit `"q100x0"`, which returns `NA`. Every probability the package itself uses is on the grid.

See also

[q_label] writes these labels. vignette("pipeline", package = "csalert") calls this function in its naming-grammar section. It is how generic tooling recovers the probability behind a `_qNNxN` column.

Other naming grammar functions: csfmt_interpret(), csfmt_parse(), csfmt_var(), q_label()

Examples

q_value(c("q02x5", "q50x0", "q97x5"))
#> [1] 0.025 0.500 0.975

# unparseable labels come back NA, including the three-digit q100x0
q_value(c("q100x0", "not_a_label"))
#> [1] NA NA