Skip to content

Instantly share code, notes, and snippets.

@wrathematics
Created November 26, 2014 19:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrathematics/2861e5e93dda849fb442 to your computer and use it in GitHub Desktop.
Save wrathematics/2861e5e93dda849fb442 to your computer and use it in GitHub Desktop.
"genderize"
### 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