私はR
は非常に具体的な町や他の場所のリストを実装していないと思います。したがって、私はウェブ上のリストを検索するだろう。このようなリストをお持ちの場合は、
grep("Tulsa", sentence, fixed = T) # [1] 1
grep("Tulsaa", sentence, fixed = T) # integer(0)
であなたは、リストで動作することができますが、物事は厳しいれる可能性があります:
sentences <- c("I am travelling to Tulsa", "I am travelling to Washington and York",
"I am travelling to Tulsa and New York")
cities <- c("Tulsa", "New York", "York")
grep(cities[1], sentences, fixed = T) # [1] 1 3
grep(cities[2], sentences, fixed = T) # [1] 3
grep(cities[3], sentences, fixed = T) # [1] 2 3
私はそれが役に立てば幸い。スピードの最適化は別のトピックになります...
応答ありがとうございます。出来た。それは、リストのdicitonaryの種類のリストを作成することは可能ですか(同じ "タルサ"としてハードコーディングの代わりに)参照してください可能であれば助けることができます –
@SijoK私の編集を参照してください – Christoph
彼は非常に助けて –