Skip to contents

Counting is done over *distinct records*, deduplicated by row number, not over the rows of the candidate table: a cross join repeats every record once per candidate, so counting the rows would report frequencies proportional to how many candidates each record happens to have.

Usage

value_frequencies(
  dat_raw_anon,
  target,
  row_number = "ROW_NUMBER",
  source = c("anon", "raw", "pooled"),
  .fn_name = "value_frequencies"
)

Arguments

dat_raw_anon

dataframe of raw_anon form

target

target column

row_number

name of the row-number column *before* the RAW_/ANON_ prefixing done by [join_raw_anon_data()] (default: "ROW_NUMBER")

source

which side to count: `"anon"` (default), `"raw"` or `"pooled"`. The default is `"anon"` because the released table is available to any attacker – estimating rarity from it needs no knowledge the adversary does not already have, which is what makes this weighting cheap to justify.

.fn_name

name used in error messages; a function that wraps this one passes its own name so the message points at the function the user actually called

Value

a data frame with columns `VALUE`, `COUNT` and `SHARE`, ordered by decreasing count, plus an `n_records` attribute giving the number of records counted

Examples

d <- create_dummy_qi_data(people = 30, seed = 1)
value_frequencies(join_raw_anon_data(d, d), "ZIP")
#>   VALUE COUNT     SHARE
#> 1  Z001     6 0.2000000
#> 2  Z005     6 0.2000000
#> 3  Z002     5 0.1666667
#> 4  Z003     5 0.1666667
#> 5  Z004     5 0.1666667
#> 6  Z006     3 0.1000000