Skip to contents

Reads a collapsed column of numeric timestamps (or day numbers, or any ordered numeric marker) and compares `max - min` – how long the record was active for – between the two sides.

Usage

score_span(
  dat_raw_anon,
  target,
  row_number = "ROW_NUMBER",
  split = ":",
  method = c("log_ratio", "absolute", "relative"),
  generalized = c("stop", "warn", "ignore"),
  .fn_name = "score_span"
)

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")

split

literal separator between the elements of the collapsed column (default ":")

method

passed to the same comparison [score_count()] uses

generalized

what to do when `target` turns out to hold generalised values on the ANON side: `"stop"` (default), `"warn"` or `"ignore"`.

.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 "reid_scores" table (a distance: smaller is a better match)

Details

The span is a different fact from both the number of events and their shape: twenty purchases in one week and twenty spread over two years describe different people. Comparing spans with `method = "log_ratio"` for the same reason [score_count()] does: the difference between a one-day and a one-month span matters far more than between two and three years.

See also

[score_containment()] for generalised columns.

Examples

raw <- data.frame(ROW_NUMBER = 1:3, T = c("1:2:3", "1:40", "5:6:7:80"))
match_greedy(score_span(join_raw_anon_data(raw, raw), "T"))
#>   ANON_ROW_NUMBER RAW_ROW_NUMBER CONFIDENCE RESULT
#> 1               1              1  1.5137641   TRUE
#> 2               2              2  0.4758222   TRUE
#> 3               3              3  0.3751024   TRUE