does a value name a region rather than a single value?
Source:R/generalize.R
is_generalized_value.Rd`TRUE` for a value that is structurally a *generalisation*: an interval covering more than one point (`"[30,40)"`, `"30代"`, `"30-39"`, `"65以上"`), or a suppression mask (`"*"`, `"135****"`). `FALSE` for an ordinary value, including a bare number – `"35"` parses as the degenerate interval `[35, 35]`, which is a value and not a region.
Usage
is_generalized_value(x, units = generalization_units())Details
`NA` is `FALSE`. A missing value can mean anything, and treating it as a generalisation would flag every column that merely has a gap in it.
The ASCII `"30s"` decade form is only accepted for a multiple of ten. [parse_generalized_interval()] reads `"8s"` as `[8, 18)`, which is right for containment (a hierarchy may legitimately declare such a node) but wrong here: over 200,000 random two-character strings, 0.256 digit + `"s"` and every one of them was reported as a generalisation – which is how this check first stopped a passing test that had nothing to do with generalisation. Requiring a multiple of ten drops the rate to 0.0245 and nobody writes "the 8s" for a decade. The restriction is on the ASCII form only: `"8代"` needs a character no alphanumeric string can produce, so it costs nothing to read it as written (Issue #92).
A *categorical* generalisation cannot be recognised this way: nothing about the string `"東京都"` says it contains `"千代田区"`. That relationship lives in a declared hierarchy, so this returns `FALSE` for it. See the note at the head of `R/generalize.R`.
See also
[score_containment()], the score to use once a column turns out to hold generalised values.
Examples
is_generalized_value(c("37", "30s", "[30,40)", "135****", "M", NA))
#> [1] FALSE TRUE TRUE TRUE FALSE FALSE