# NOT RUN {
# Exact match
attr_1 <- c(1, 1, 1, NA, NA, NA, NA, NA)
attr_2 <- c(NA, NA, 2, 2, 2, NA, NA, NA)
links(criteria = list(attr_1, attr_2))
# User-defined tests using `sub_criteria()`
# Matching `sex` and a 20-year age range
age <- c(30, 28, 40, 25, 25, 29, 27)
sex <- c("M", "M", "M", "F", "M", "M", "F")
f1 <- function(x, y) abs(y - x) %in% 0:20
links(criteria = sex,
sub_criteria = list(cr1 = sub_criteria(age, match_funcs = f1)))
# Multistage matches
# Relevance of matches: `forename` > `surname`
data(staff_records); staff_records
links(criteria = list(staff_records$forename, staff_records$surname),
data_source = staff_records$sex)
# Relevance of matches:
# `staff_id` > `age` (AND (`initials`, `hair_colour` OR `branch_office`))
data(missing_staff_id); missing_staff_id
links(criteria = list(missing_staff_id$staff_id, missing_staff_id$age),
sub_criteria = list(cr2 = sub_criteria(missing_staff_id$initials,
missing_staff_id$hair_colour,
missing_staff_id$branch_office)),
data_source = missing_staff_id$source_1)
# Group expansion
match_cri <- list(c(1,NA,NA,1,NA,NA),
c(1,1,1,2,2,2),
c(3,3,3,2,2,2))
links(criteria = match_cri, expand = TRUE)
links(criteria = match_cri, expand = FALSE)
links(criteria = match_cri, shrink = TRUE)
# }
Run the code above in your browser using DataLab