I'm trying to add a new column with the values "N"; "NE"; "CO"; "S" and "SE based on the values of the Group.2 column, say (AL, CE, BA = NE).
Tried using mutate with case_when and it didn't work
esc_c %>%
mutate(
reg_uf = case_when(
Group.2 == "GO" | "CO",
Group.2 == "TO" |"CO",
Group.2 == "DF" |"CO",
Group.2 == "MT" |"CO",
Group.2 == "MS" |"CO", TRUE ~ Group.2))
would apreciate an answer using dplyr
| roup.1 | Group | Group.2 | Group.3 | CO_UF_END | TP_ESCOLARIDADE | Cod_IBGE | uf_sigla | uf_des |
|---|---|---|---|---|---|---|---|---|
| 1 | 12 | AC | Acre | 12 | 3.921569 | 1200417 | NA | NA |
| 2 | 27 | AL | Alagoas | 27 | 3.783784 | 2704233 | NA | NA |
| 3 | 16 | AP | Amapá | 16 | 3.815789 | 1600393 | NA | NA |
| 4 | 13 | AM | Amazonas | 13 | 3.937500 | 1302661 | NA | NA |
| 5 | 29 | BA | Bahia | 29 | 3.726444 | 2916394 | NA | NA |
| 6 | 23 | CE | Ceará | 23 | 3.886076 | 2307054 | NA | NA |
| 7 | 53 | DF | Distrito Federal | 53 | 3.957739 | 5300108 | NA | NA |
| 8 | 32 | ES | Espírito Santo | 32 | 3.905660 | 3203381 | NA | NA |
| 9 | 52 | GO | Goiás | 52 | 3.897945 | 5210048 | NA | NA |
|would be~i.e.Group.2 == "GO" | "CO"would beGroup.2 == "GO" ~ "CO"