Joins two datasets using row-index pairs returned by record linkage.
Usage
join_records(
links,
A,
B,
all = FALSE,
all_A = all,
all_B = all,
suffixes = c(".a", ".b"),
keep_from_links = FALSE
)Arguments
- links
A linkage result from
mec(),predict.rec_lin_model(),mec_blocking(), or adata.frame/data.tablewith columnsaandb.- A
A
data.frameordata.table.- B
A
data.frameordata.table.- all
Logical indicating whether to include unmatched records from both datasets.
- all_A
Logical indicating whether to include unmatched records from
A.- all_B
Logical indicating whether to include unmatched records from
B.- suffixes
A character vector of length two used to distinguish columns from
AandBwhen their names conflict with each other or with linkage columns.- keep_from_links
Logical or character vector. If
FALSE, only columnsaandbare kept from the linkage table. IfTRUE, all non-index linkage columns are kept. If a character vector, only the selected non-index linkage columns are kept.
Value
Returns a data.table containing:
a– row indices of records fromA,b– row indices of records fromB,columns selected from
links– linkage metadata kept according tokeep_from_links, if requested,columns from
A– values of records fromA, withsuffixes[1]added when needed,columns from
B– values of records fromB, withsuffixes[2]added when needed.
Note
The function follows the general design of link(), adjusted
to linkage results used in automatedRecLin.
Examples
A <- data.frame(name = c("James", "Emma"), age = c(30, 28))
B <- data.frame(name = c("James", "Emily"), city = c("Boston", "Denver"))
links <- data.frame(a = 1, b = 1, ratio = 10)
join_records(links, A, B)
#> a b name.a age name.b city
#> <int> <int> <char> <num> <char> <char>
#> 1: 1 1 James 30 James Boston