Learn R Programming

DemografixeR

‘DemografixeR’ allows to estimate gender, age & nationality from a name. The package is an API wrapper of all 3 ‘Demografix’ API’s - all three APIs supported in one package:

Documentation

You can find all the necessary documentation about the package here:

Installation

You can install the CRAN release version of DemografixeR following this R command:

install.packages("DemografixeR")

You can also install the development version of DemografixeR following these R commands:

if (!require("devtools")) install.packages("devtools")
devtools::install_github("matbmeijer/DemografixeR")

Examples

These are basic examples, which shows you how to estimate nationality, gender and age by a given name with & without specifying a country. The package takes care of multiple background tasks:

  • API pagination
  • Duplicated names (one request made per name)
  • Missing values
  • Workflow integration (e.g. with dplyr or data.table)
library(DemografixeR)

#Simple example without country_id
names<-c("Ben", "Allister", "Lucie", "Paula")
genderize(name = names)
#> [1] "male"   "male"   "female" "female"
nationalize(name = names)
#> [1] "AU" "ZA" "CZ" "PT"
agify(name = names)
#> [1] 48 44 24 50

#Simple example with
genderize(name = names, country_id = "US")
#> [1] "male"   "male"   "female" "female"
agify(name = names, country_id = "US")
#> [1] 67 46 65 70

#Workflow example with dplyr with missing values and multiple different countries
df<-data.frame(names=c("Ana", NA, "Pedro",
                       "Francisco", "Maria", "Elena"),
                 country=c(NA, NA, "ES",
                           "DE", "ES", "NL"), stringsAsFactors = FALSE)

df %>% dplyr::mutate(guessed_nationality=nationalize(name = names),
                guessed_gender=genderize(name = names, country_id = country),
                guessed_age=agify(name = names, country_id = country)) %>% 
  knitr::kable()
namescountryguessed_nationalityguessed_genderguessed_age
AnaNAPTfemale58
NANANANANA
PedroESPTmale69
FranciscoDECLmale58
MariaESCYNA59
ElenaNLCCfemale69

#Detailed data.frame example:
genderize(name = names, simplify = FALSE, meta = TRUE) %>% knitr::kable()
nametypegenderprobabilitycountapi_rate_limitapi_rate_remainingapi_rate_resetapi_request_timestamp
2Bengendermale0.9577991100083152142020-05-04 22:33:05
1Allistergendermale0.98129100083152142020-05-04 22:33:05
3Luciegenderfemale0.9985580100083152142020-05-04 22:33:05
4Paulagenderfemale0.9874130100083152142020-05-04 22:33:05

Disclaimer

  • This package is in no way affiliated to the Demografix ApS company, the owner of the ‘genderize.io’, ‘agify.io’ and ‘nationalize.io’ APIs.
  • An open mind towards gender & gender diversity is promoted, warning that the results from the ‘genderize.io’ API reflect an oversimplification of gender identity, gender roles and the meaning of ‘gender’. For more information visit the active discussion in the following Wikipedia article.

Code of Conduct

Please note that the ‘DemografixeR’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

MIT © Matthias Brenninkmeijer

Copy Link

Version

Install

install.packages('DemografixeR')

Monthly Downloads

35

Version

0.1.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Matthias Brenninkmeijer

Last Published

May 6th, 2020

Functions in DemografixeR (0.1.1)

supported_countries

Retrieve the supported countries for each API
DemografixeR

DemografixeR: Estimate gender, age and nationality from a name
agify

'Agifies' a name
nationalize

'Nationalizes' a name
save_api_key

Saves the API key for future functions
genderize

'Genderizes' a name
%>%

Pipe operator
remove_api_key

Removes saved API key
get_api_key

Get previously saved API keys