Skip to contents

Produces one string per row that encodes the organization, tax year, name, and standardized title. The string is meant to be human-legible for debugging and to be fed to create_emp_ids() for hashing. Where two rows produce an identical string (a genuine duplicate record within an organization-year) a -D{k} occurrence suffix is appended so the returned vector is always unique.

Usage

build_id_string(
  df,
  org_id = "ein",
  year = "taxyr",
  name = "name",
  title = "title.standard"
)

Arguments

df

A data frame.

org_id, year, name, title

Column names in df for the organization id, tax year, person name, and standardized title.

Value

A unique character vector of length nrow(df).

Details

This replaces the draft create_hash_string(), which interpolated the literal strings "EIN2" and OID instead of the corresponding columns and whose argument names did not match the call site.

Examples

df <- data.frame(
  ein = c("11", "11"), taxyr = c(2019, 2020),
  name = c("Jane Roe", "Jane Roe"), title.standard = c("CEO", "CEO")
)
build_id_string(df)
#> [1] "EIN-11-Y-2019-NAME-JANE-ROE-TITLE-CEO"
#> [2] "EIN-11-Y-2020-NAME-JANE-ROE-TITLE-CEO"