fmap_to_ranges: Reverse-Lookup Range Bounds from Labels

View source: R/utilities.R

fmap_to_rangesR Documentation

Reverse-Lookup Range Bounds from Labels

Description

Given a vector of values that match the labels of a range-based format, returns the corresponding low / high bounds (and inclusivity flags) for each input. Useful for reconstructing the underlying range from a coded value.

Usage

fmap_to_ranges(x, fmt)

Arguments

x

A vector of values to look up against the format's labels. Coerced to character before matching.

fmt

A ks_format object, or a character name of a format registered in the global library.

Details

For multilabel formats where the same label maps to several ranges, only the first matching range is returned. For full multi-match behaviour, call franges() directly and join on label.

Value

A data.frame with one row per element of x and columns low, high, inc_low, inc_high. Rows where the input does not match any range label contain NA.

See Also

franges

Examples

fparse(text = '
VALUE visit_ther (numeric)
  [LOW,  1] =  0
  [ 8, 22] =  2
  [22, 36] =  4
  [37, 50] =  6
;
')
fmap_to_ranges(c(0, 2, 4, 6), "visit_ther")
fclear()

ksformat documentation built on May 21, 2026, 9:07 a.m.