I tried to create a column "gender" based on the name of people. I have multiple names, sometimes composed of two names (for instance William Alexander). Here is my code (an extract, i have much more than that names)
df$gender <- ifelse(grepl("LUIS|OSCAR|HELMUT|PABLO",df$names, ignore.case = T), "Man",
ifelse(grepl("VIVIANA|DIANA|ADRIANA|ALBA",df$names, ignore.case = T), "Woman","NA"))
I though that the code was working perfectly well, but i denoted the following thanks to a group_by :
| Names | Gender |
|---|---|
| Luis | Man |
| Alba Tatiana | Man |
I don't understand why a woman name appears as a man name even if i specified that it should takes the value "Woman"
Aucun commentaire:
Enregistrer un commentaire