Extracting list of locations from text using R I have a string containing many words [not sentences], I want to know how I can extract all the words that correspond to a location in that string for example:

text&lt;-c("China","Japan","perspective","United Kingdom","formatting","clear","India","Sudan","United States of America","Bagel","Mongolian",...)


The output should be:   

 &gt; China, Japan, United Kingdom, Mongolian


something of the type. Basically I am looking at extracting locative information from random text.
This is a very general problem I am looking for guidance on how to model my solution, is there any dataset or something I can use to compare or extract information from. I don't want to carry out word by word comparison.

I have looked up OpenNLP but I am not sure how to use it's location-models for carrying out Named Entity Recognition in R. In the above example there are only countries but I would like to identify other places, such as provinces, states, counties, cities, etc. as well. 
I am new to machine learning and R-programming, any guidance is greatly appreciated.
I use the function grepl() for this.

text&lt;-c("China","Japan","perspective","United Kingdom","formatting","clear",
"India","Sudan","United States of America","Bagel","Mongolian")

#Make a logical vector
arg&lt;-grepl("China",text)|grepl("Japan",text)|grepl("UnitedKingdom",text)|
grepl("Mongolian",text)

#Pick out from text
text[arg]