Skip to contents

Appends a typed rule, or replaces the rule with the same name (upsert). The payload arguments depend on type:

filter, check

column, op, values (structured) or expr (a predicate string). op in in, not_in, ==, !=, >, >=, <, <=, between, is_true, is_false.

subset

subset – a vector of entity ids to keep (captured).

require

a cross-year condition on the source, executed by resolve_frame() rather than apply_sfw(). table (default "P00"), present_in ("all" for a balanced frame, "any", or a minimum year count), and optionally a per-filing predicate as column/op/values plus holds ("every" year, the default, or "any" year). An expr string is rejected: it cannot be pushed to the source.

label

map (an id-named vector) or from (a data frame) with keys and label column names; label also names the derived column.

select

vars, scope, tables, drop (resolved via field_concordance and field_concordance_pf). scope takes a fields_in_scope() value or a variable_scope code; the 990-vs-990EZ scopes do not apply to a 990PF panel, which panelize_pf() rejects. tables takes table-name prefixes, a part code such as "P08", or a 990PF part code such as "PF01".

dedup

group, partial, amended, timestamp column overrides for deduplicate().

refresh

fn – a function taking and returning a data frame.

view

rows, cols, value, fun – a crosstab/tapply summary.

function

value/code (a string) or fn (a function).

Usage

add_rule(sfw, name = NULL, type, ...)

Arguments

sfw

A sample frame.

name

Rule name. Empty/NULL auto-generates <type>_<n>. An existing name replaces that rule.

type

One of the rule types above.

...

Type-specific payload (see Details).

Value

The updated sample frame.