I would like to categorize the cities in city_1, city_2 etc in my dataset.. but using a key value mapping. For example I would like to retrieve "city_1" giving 4059 as value and so on..
Do you have some suggestions on how can I solve this? Thank you!
This is the list:
zip_codes <- list("city_1" =c(4000, 4001, 4005, 4009, 4010, 4018, 4019, 4020, 4030, 4031, 4051, 4052, 4053, 4054, 4055, 4056, 4057, 4058, 4059))
|__A____|___B___|
|__4000_|_city_1|
|__4009_|_city_1|
|__4059_|_city_1|
|__4059_|_city_1|
|__4565_|_city_2|
So for example, I have a dataset, in which zip codes such as the ones above appear in the columns and I would like to map to which place each of those zip_code belongs. I want to make column "B" from the zip code list. I was thinking to a key-values mapping, but maybe in R it is not the best way....Do you have better ideas?
We can use
enframefromtidyverseand then we can extract with