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
Just for fun, you can use strsplit
strsplit
> x <- c("London, UK", "Paris, France", "New York, USA") > sapply(strsplit(x, ","), "[", 1) [1] "London" "Paris" "New York"