I have the following data frame in R out of which I'd like to create a new column containing the Nut for each municipal (See second table). "Nut" refers simply to a higher hirachy level of municipalities in portugal. For later analysis I need to group the data by Nuts. The entire dataframe consists of 308 municipalities and 25 Nuts.
Does someone have a suggestion on how to approach this task? Since the number of municipals in each Nut differes I have difficulties on where to begin.
geo-group | nuts_municipal |
---|---|
Nut III | Alto Minho |
Municipal | Arcos de Valdevez |
Municipal | Caminha |
Municipal | Monção |
Municipal | Ponte da Barca |
Nuts III | Ponte da Barca |
Municipal | Amares |
Municipal | Barcelos |
Municipal | Braga |
Nuts III | Fafe |
Municipal | Ave |
This is what I'd like to have as a final result.
geo-group | nuts_municipal | Nut |
---|---|---|
Nut III | Alto Minho | |
Municipal | Arcos de Valdevez | Alto Minho |
Municipal | Caminha | Alto Minho |
Municipal | Monção | Alto Minho |
Municipal | Ponte da Barca | Alto Minho |
Nut III | Cávado | |
Municipal | Amares | Cávado |
Municipal | Barcelos | Cávado |
Municipal | Braga | Cávado |
Nut III | Ave | |
Municipal | Fafe | Ave |
Municipal | Mondim de Basto | Ave |
I have difficulties on where to begin and so far haven't found any appreach.