How to move observation one columns to another column?




I have directory data file and just trying to do descriptive analysis. Now I have two column name city and zipcode.
Some city name saved in to zipcode columns. now I want to move those city name from zipcode columns to city columns.
Sample Data:

Tumbol Thatum Amphoe Tha Tum Province Surin 32120 Surin 32120
Province Ranong Ranong
154 Moo 6 Soi Wat Koosrang Suksawat Tumbol Nai Khlong Bang Plakot Amphoe Phra Samut Chedi Province Samut Prakan 10290 Samut Prakan 10290
Tumbol Naimueang Amphoe Mueang Chai Nat Province Chai Nat 17000 Chai Nat 17000
Province Chiang Mai Chiang Mai

Here we can see another problem is some city name half in city column and half in zipcode column so how can we correct it?

How can we extract city name from address and impute in city columns? there are 113 cities so we can’t do manually.

Can anyone have any Idea how can I do in R?

Thanks in Advance


How many rows of data is affected. In R write your own logic where you read one row after another, check if zip has character fields, if so concatenate with State field and so on.

if number of rows is 113, just use excel and manually clean it. That is the fastest way.


Thank you for kind Reply.
Dataset contains 1L observations So I can’t check manually. But I tried extract City name from Address and impute in City columns.