mercredi 22 avril 2020

How to i create a dummy column whilst using an if statement?

I have a datsaset which shows tax paid by a number of different local authorities.

I want to create a dummy column, so that if I state specific localauthorities in an if statement, if they match it returns a value of 1, if not it returns a value of 0.

I have tried: mutate_if(tax_data, localauthority %in% c('Exeter', 'Glasgow', 'Oxford'), funs(dummy==1)) mutate_if(tax_data, localauthority != c('Exeter', 'Glasgow', 'Oxford'), funs(dummy==0))

Can anyone provide any help on how i can use an if statement whilst creating a dummy column to satisfy this condition?

Aucun commentaire:

Enregistrer un commentaire