Vlastní fuzzy porovnávání

Intermediate Regular Expressions in R

Angelo Zehr

Data Journalist

Kombinace dvou fuzzy porovnání

tabulky filmů

Intermediate Regular Expressions in R

Kombinace dvou fuzzy porovnání

zvýrazněné sloupce

Intermediate Regular Expressions in R

Fuzzy porovnání: pomocné funkce

Pro porovnání řetězců:

small_str_distance <- function(left, right) {
  stringdist(left, right) <= 5
}

Pro porovnání čísel:

close_to_each_other <- function(left, right) {
  abs(left - right) <= 3
}
Intermediate Regular Expressions in R

Fuzzy join

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

Fuzzy join: výsledek

spojená tabulka

Intermediate Regular Expressions in R

Pojďme si procvičit!

Intermediate Regular Expressions in R

Preparing Video For Download...