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
If the this was a column in a dataframe, we can use tidyverse.
library(dplyr) x <- c("London, UK", "Paris, France", "New York, USA") x <- as.data.frame(x) x %>% separate(x, c("A","B"), sep = ',') A B 1 London UK 2 Paris France 3 New York USA