Keeps only the atoms belonging to unit at frame, and rebuilds the member
vocabularies accordingly.
filter_scale(x, frame, unit, drop_empty_frames = FALSE)A NestedScale.
Frame that unit belongs to.
Character vector of codes to keep.
Drop frames left with no codes at all.
A NestedScale.
A genuine subset is a SAMPLE and is book-kept as one: meta$coverage
records, per weight column, the kept fraction of the ROOT parent's total (so
filters compose against the original object), meta$parent_totals stores
those root totals (making the coverage claim verifiable by the validator),
meta$parent_name records the parent, and meta$name is mangled to
"parent[frame:codes]" so a sample never impersonates its parent in the
crosswalk registry or in join_scale() column names. A filter that keeps
every atom is a true no-op. Read the fraction back with scale_coverage().
s <- scale_example()
p <- filter_scale(s, "sector", "P")
p
#> NestedScale: example[sector:P]
#> Description: Synthetic example: reused code, non-nesting frame pair, and an unassigned atom
#> Frames (4, coarsest first):
#> - sector (1)
#> - class (2)
#> - group (2)
#> - unit (4)
#> Atoms: 4
#> Weights: size, count (default: size)
scale_coverage(p)
#> size count
#> 0.3225806 0.6666667