fmap_strata: Build a Vector of Stratified Range Mappings

View source: R/utilities.R

fmap_strataR Documentation

Build a Vector of Stratified Range Mappings

Description

Companion to fmap_ranges for the stratified_range format type. Each row pairs a stratum (e.g. study arm, subject id, or a composite key produced by fputk()) with a numeric / Date / POSIXct range and a label. The returned ks_fmap vector carries the chosen sep as an attribute so that fnew(type = "stratified_range") picks it up automatically.

Usage

fmap_strata(
  stratum,
  low,
  high,
  label,
  inc_low = TRUE,
  inc_high = FALSE,
  sep = "|",
  date_format = NULL
)

Arguments

stratum

Character vector of stratum identifiers.

low, high

Range bounds. See fmap_ranges.

label

Character vector of labels.

inc_low, inc_high

Logical, length 1 or length(low). See fmap_ranges.

sep

Separator inserted between stratum and range key. Must match the sep subsequently passed to fputk.

date_format

Optional strptime format string.

Value

A ks_fmap object with an attached "strata_sep" attribute.

See Also

fmap_ranges, fputk, fnew

Examples

visits <- fmap_strata(
  stratum  = c("ARM_A", "ARM_A", "ARM_B"),
  low      = c(0, 7, 0),
  high     = c(7, 14, 10),
  label    = c("Baseline", "Week 1", "Baseline")
)
fnew(visits, type = "stratified_range", range_subtype = "numeric",
     name = "visit_window")
fputk(c("ARM_A", "ARM_B"), c(3, 5), format = "visit_window")
fclear()

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