inpowell / modulartabler

MIT License
3 stars 0 forks source link

Add support for optional other/total mappings in RangeMappingTable #1

Closed PeterM74 closed 2 months ago

PeterM74 commented 2 months ago

The flexibility of BaseMappingTable (and by extension MultiMappingTable) allows the user to optionally specify missing and total categories as not all categories/totals are relevant for reporting.

It would be useful if RangeMappingTable allowed the user to specify NULL for either/both the .other and .total parameters which will exclude them from the mapping. E.g.

RangeMappingTable$new(
    table_name = 'Variable',
    data_col = 'var',
    "<20" = c(-Inf, 20),
    "20-34" = c(20, 35),
    "35+" = c(35, Inf),
    .other = NULL,
    .total = NULL
  )

# A tibble: 3 × 2
  Variable  .var
  <fct>    <int>
1 <20          1
2 20-34        2
3 35+          3

I will submit a PR to address this