Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 LevenStein逻辑以最小的差异获取所有字符串_R_Levenshtein Distance - Fatal编程技术网

R LevenStein逻辑以最小的差异获取所有字符串

R LevenStein逻辑以最小的差异获取所有字符串,r,levenshtein-distance,R,Levenshtein Distance,假设我有一个带值的datframe Mtemp: -----+ code | -----+ Ram | John | Tracy| Aman | 我想将其与dataframe进行比较 M2: 我想得到结果,这样对于Mtemp中的每个值,我将在距离2内得到最大2个可能匹配的M2 我用过 tp<-as.data.frame(amatch(Mtemp$code,M2$code,method = "lv",maxDist = 2)) tp$orig<-Mtemp$code colname

假设我有一个带值的datframe

Mtemp:
-----+
code |
-----+
Ram  |
John |
Tracy|
Aman |
我想将其与dataframe进行比较 M2:

我想得到结果,这样对于Mtemp中的每个值,我将在距离2内得到最大2个可能匹配的M2

我用过

tp<-as.data.frame(amatch(Mtemp$code,M2$code,method = "lv",maxDist = 2))
tp$orig<-Mtemp$code
colnames(tp)<-c('Res','orig')

请告诉我一种方法,可以为Lev distance=2的每个Mtemp字符串获取2个值(如果可能),基本R中的
adist
函数将计算编辑距离。您可以使用此结果得出至少两个观察值。base R中的
adist
函数将计算编辑距离。您可以使用此结果得出至少两个观察值。
tp<-as.data.frame(amatch(Mtemp$code,M2$code,method = "lv",maxDist = 2))
tp$orig<-Mtemp$code
colnames(tp)<-c('Res','orig')
Res  |orig  
-----+-----
3    |Ram
5    |John
6    |Tracy
4    |Aman