mercredi 3 novembre 2021

How to chain ifelse?

I'm trying to regroup cities.

Like city number 11 + 12 = 111 21 + 22 = 222

This is my code and it shows no error but does not change anything.

 merged <- merged %>% 
  mutate(region2 = ifelse(region == c(11,31), 11, 
                          ifelse(region == c(27, 33, 34), 27, region2)))

I still can find 31 in col. region2

What should I do?

Aucun commentaire:

Enregistrer un commentaire