How to split column into two in R using separate

Specify the separating character

dataframe %>% separate(Location, c('Latitude', 'Longitude'), sep=",")

But, extract looks cleaner for this since you can remove the “()” at the same time

dataframe %>% extract(x, c("Latitude", "Longitude"), "\\(([^,]+), ([^)]+)\\)")

Leave a Comment