理解字符串距离

R 中级正则表达式

Angelo Zehr

Data Journalist

什么是字符串距离?

rain ran run

颜色刻度

R 中级正则表达式

什么是字符串距离?

sunday surday saurday saturday

颜色刻度

R 中级正则表达式

真实世界的应用

emile brown typo

R 中级正则表达式

screenshot google

R 中级正则表达式

R 中的字符串距离

library(stringdist)
stringdist("saturday", "sunday", method = "lv")

返回:

3

是否相同:

stringdist("sunday", "saturday", method = "lv")
R 中级正则表达式

查找匹配项

amatch(
  x = "Sonday",
  table = c("Friday", "Saturday", "Sunday"),
  maxDist = 1,
  method = "lv"
)

返回:

3
R 中级正则表达式

让我们练习吧!

R 中级正则表达式

Preparing Video For Download...