Basically, I have a data frame called "top100_retailers". It has a column named "Headquarter" that contains the city, state(For example: "Bentonville, Ark."). I want to create 2 new columns called "City" and "State". How do I only take the city information and assign it to the new "City" column and only take the state information and assign it to the new "State" column?
We can do this with
library(tidyr) top100_retailers <- separate(top100_retailers, Headquarter, into = c("City", "State"))
If we want to keep the 'Headquarter' column as well, use the
remove = FALSE argument as it is by default