Skip to content

Instantly share code, notes, and snippets.

@marcusrehm
Last active August 29, 2015 14:15
Show Gist options
  • Save marcusrehm/5028bf105aa79e381945 to your computer and use it in GitHub Desktop.
Save marcusrehm/5028bf105aa79e381945 to your computer and use it in GitHub Desktop.
Simple function to acquire genders for a vector of persons first names.
require('jsonlite')
#Get genders for a vector of first names.
#Usage: genders <- getGenders(c('joão', 'fábio', 'lúcia', 'rúbens'))
getGenders <- function (raw_names) {
url_api <- 'http://api.genderize.io?'
for(i in 1:length(raw_names)) {
url_api <- paste(url_api, 'name[', i - 1, ']=',
iconv(raw_names[i], to='ASCII//TRANSLIT'),
'&',
sep = '')
}
fromJSON(url_api)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment