2016-10-25 10 views
0

agrep関数を使用して文字列をRに一致させようとしています。私は理解していない、なぜそれがどのような価値を戻していない。私は、指定されたテキストのクローズドマッチを与える解決策を探しています。与えられた例で表示する必要があります"ms sharda stone crusher prop rupa"Rのagrep関数がテキストマッチングのために機能していません

私はどんな助けにも感謝します。 ありがとうございます。

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) 
+0

あなたが式全体 '「ミリ秒sharda石の粉砕機のプロペラルパ」を'と一致するようにしようとしているので、してみてください'なぜ' agrep'を使用していて、 'grep'を使わないのですか?'、 '' grantp''、 '' ignp.case = T''、 '' – timat

+0

しかし、私は表現全体にマッチする方法を探しています。それを行う方法はありますか?ありがとうございました! – honey

+0

したがって、値は返されません。式全体があなたのベクトルに含まれていないからです。あなたが探している出力を表示してください...(あなたの応答を編集して) – timat

答えて

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" 

あなただけの最も近いものをしたい場合は以下を参照してください best match

+0

これで動作します。どうもありがとう... – honey

関連する問題