Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 类别模糊匹配_R_Text Mining_Fuzzy Search - Fatal编程技术网

R 类别模糊匹配

R 类别模糊匹配,r,text-mining,fuzzy-search,R,Text Mining,Fuzzy Search,我正在尝试使用agrep函数根据公司名称模糊匹配两个不同的数据帧。为了改进匹配,我只希望匹配位于同一国家/地区的公司 df1: df2: Company ISO Company ISO Aalberts Industries NL Aalberts NL Allison NL

我正在尝试使用agrep函数根据公司名称模糊匹配两个不同的数据帧。为了改进匹配,我只希望匹配位于同一国家/地区的公司

 df1:                             df2:
 Company               ISO        Company                ISO
 Aalberts Industries   NL         Aalberts               NL
 Allison               NL         Allison transmission   NL
 Allison               UK         Allison transmission   UK
我使用以下函数进行匹配:

testb$test <- ""
for(i in 1:dim(testb)[1]) {x2 <- agrep(testb$name[i], testa$name, ignore.case=TRUE, value=TRUE, max.distance = Inf, useBytes = TRUE, fixed = TRUE)
                     x2 <- paste0(x2,"")
                     testb$test2[i] <- x2
}

testb$test尝试使用
数据建立索引。表
包:

您的公司列似乎太不相同,无法与
agrep()
一致准确地匹配。例如,只有将
max.distance
设置为大于10的值时,“Aalberts Industries”才会与“Aalberts”匹配。同样的字符串距离也会报告“代数”和“胡同”之间的匹配——一点也不接近。我建议在匹配之前清除公司栏中不必要的单词

对不起,我想对此发表评论,但我没有必要的声誉。也许有人能帮我把这转化成评论