📅  最后修改于: 2022-03-11 14:55:09.796000             🧑  作者: Mango
pairs <- expand.grid(x = seq_len(nrow(dta)), y = seq_len(nrow(dta))) %>%
# Only need to compare i to all records j, with j > i
filter(y > x) %>%
left_join(dta, by = c(x = 'i')) %>% rename(cityx = city, nx = n) %>%
left_join(dta, by = c(y = 'i')) %>% rename(cityy = city, ny = n) %>%
mutate(similarity = stringsim(cityx, cityy, method = "jw")) %>%
arrange(desc(similarity))