Created
November 26, 2014 19:29
-
-
Save wrathematics/2861e5e93dda849fb442 to your computer and use it in GitHub Desktop.
"genderize"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Determining (poorly) the sex of a person based on their name. | |
### Based on this post: http://thedailywtf.com/articles/genderize | |
genderize <- function(name) | |
{ | |
regex <- "(ua|pher|andy|elijah)$" | |
if (grepl(x=name, pattern=regex, ignore.case=TRUE)) | |
return("male") | |
regex <- "(a|i|y|ah|ee|et|ette|elle|fer|ine|lyn|ie|anne|een|en|er|yn|ynn|kim|rachel|lind|pam|sue)$" | |
if (grepl(x=name, pattern=regex, ignore.case=TRUE)) | |
return("female") | |
return("male") | |
} | |
genderize("jenny") | |
# female | |
genderize("romain") | |
# male | |
genderize("hillary") | |
# female | |
genderize("hadley") | |
# female |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment