0

我正在尝试agrep使用R. 我不明白,为什么它没有返回任何价值。我正在寻找一种解决方案,它将提供给定文本的封闭匹配。在给定的示例中,它应该显示"ms sharda stone crusher prop rupa"

我将不胜感激任何帮助。提前致谢。

x= as.vector(c("sharda stone crusher prop roopa","sharda stone crusher prop rupa"))
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 0.1, useBytes = FALSE)
character(0)
4

1 回答 1

0

这是因为你的max.distance参数。见?agrep

例如:

agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 0.2, useBytes = FALSE)
"sharda stone crusher prop rupa"
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 0.25, useBytes = FALSE)
"sharda stone crusher prop roopa" "sharda stone crusher prop rupa" 
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 9, useBytes = FALSE)
"sharda stone crusher prop rupa"
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 10, useBytes = FALSE)
"sharda stone crusher prop roopa" "sharda stone crusher prop rupa" 

如果您只想要最接近的匹配,请参见: 最佳匹配

于 2016-10-25T11:49:25.293 回答