Intermediate Regular Expressions in R
Angelo Zehr
Data Journalist
For the string comparison:
small_str_distance <- function(left, right) {
stringdist(left, right) <= 5
}
For the number comparison:
close_to_each_other <- function(left, right) {
abs(left - right) <= 3
}
fuzzy_left_join(
a, b,
by = c(
"title" = "prod_title",
"year" = "prod_year"
),
match_fun = c(
"title" = small_str_distance,
"year" = close_to_each_other
)
)
Intermediate Regular Expressions in R