I am a beginner with R. Now, I have a vector in a data.frame like this
city Kirkland, Bethesda, Wellington, La Jolla, Berkeley, Costa, Evie KW172NJ Miami, P
You can use gsub with a bit of regexp :
gsub
cities <- gsub("^(.*?),.*", "\\1", df$city)
This one works, too :
cities <- gsub(",.*$", "", df$city)