Title: | Extrapolate Gender, Age and Nationality of a Name |
---|---|
Description: | Connects to the <https://genderize.io/>, <https://agify.io/> and <https://nationalize.io/> APIs to estimate gender, age and nationality of a first name. |
Authors: | Matthias Brenninkmeijer [aut, cre] |
Maintainer: | Matthias Brenninkmeijer <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-02-23 03:00:55 UTC |
Source: | https://github.com/matbmeijer/demografixer |
Function to estimate the age from a first name. Connects directly to the agify.io API sending a request with a name and parses the response to return the predicted age.
agify( name, country_id = NULL, simplify = TRUE, apikey = get_api_key(), meta = FALSE )
agify( name, country_id = NULL, simplify = TRUE, apikey = get_api_key(), meta = FALSE )
name |
Name/s to estimate the age. Can be a single |
country_id |
Responses will in a lot of cases be more accurate if the
data is narrowed to a specific country. This optional parameter allows to
specify a specific country. The parameter must be a country code following
the common ISO
3166-1 alpha-2 country code convention. To see a list of the supported
countries use the |
simplify |
|
apikey |
Optional parameter to pass the API key. The API is free for up
to 1000 names/day. No sign up or API key needed. Yet, if more requests
would be needed, visit the agify.io store
and the obtained API key can be passed through this parameter. The API can
also be saved one time through the |
meta |
|
The function automatically handles pagination (max. 10 names per API
request), missing values & duplicated values. If a name is duplicated for
the same country_id
(if given), it will handle the request as a a
single name to save requests, returning the same value for the duplicated
names. To see more details about the API documentation, visit the
agify.io website.
The estimated age in a single character
vector form or a
data.frame
with additional information.
Please be aware about local privacy protection regulations such as GDPR when dealing with personal data.
Matthias Brenninkmeijer - https://github.com/matbmeijer
agify(name=c("Ben", "Maria"))
agify(name=c("Ben", "Maria"))
The DemografixeR is an API wrapper for the genderize.io, agify.io & nationalize.io APIs. Through the APIs it retrieves the estimated gender, estimated age and/or estimated nationality from a name. The package most important functions are the following:
Function to estimate the gender from a first name. Connects directly to the genderize.io API sending a request with a name and parses the response to return the predicted gender.
genderize( name, country_id = NULL, simplify = TRUE, apikey = get_api_key(), meta = FALSE )
genderize( name, country_id = NULL, simplify = TRUE, apikey = get_api_key(), meta = FALSE )
name |
Name/s to estimate the gender. Can be a single |
country_id |
Responses will in a lot of cases be more accurate if the
data is narrowed to a specific country. This optional parameter allows to
specify a specific country. The parameter must be a country code following
the common ISO
3166-1 alpha-2 country code convention. To see a list of the supported
countries use the |
simplify |
Defines if the result should be returned as a single vector
or a
|
apikey |
Optional parameter to pass the API key. The API is free for up
to 1000 names/day. No sign up or API key needed. Yet, if more requests
would be needed, visit the genderize.io
store and the obtained API key can be passed through this parameter. The
API can also be saved one time through the |
meta |
|
The function automatically handles pagination (max. 10 names per API
request), missing values & duplicated values. If a name is duplicated for
the same country_id
(if the parameter has been passed), it will
handle the request as a a single name to save requests, returning the same
value for the duplicated names. To see more details about the API
documentation, visit the genderize.io
website.
The estimated age in a single character
vector form or a
data.frame
with additional information.
Please be aware about local privacy protection regulations such as GDPR when dealing with personal data.
Matthias Brenninkmeijer - https://github.com/matbmeijer
genderize(name=c("Ben", "Maria"))
genderize(name=c("Ben", "Maria"))
Function to get the previously saved API key. It has the
advantage that it is not necessary to explicitly publish the key in the
users code. Just do it one time and you're set. To save an API, use the
save_api_key
function. To remove a previously saved key, use
the remove_api_key
function.
get_api_key()
get_api_key()
Returns the saved API key in the environment. If no API key has been
saved, returns NULL
value.
Please be careful when dealing with API keys and other secrets & tokens - keep them private and do not publish them.
Matthias Brenninkmeijer - https://github.com/matbmeijer
## Not run: get_api_key(type="genderize") get_api_key(type="agify") get_api_key(type="nationalize") ## End(Not run)
## Not run: get_api_key(type="genderize") get_api_key(type="agify") get_api_key(type="nationalize") ## End(Not run)
Returns the estimated nationality from a given name.
nationalize( name, simplify = TRUE, sliced = TRUE, apikey = get_api_key(), meta = FALSE )
nationalize( name, simplify = TRUE, sliced = TRUE, apikey = get_api_key(), meta = FALSE )
name |
Name/s to estimate the nationality. Can be a single
|
simplify |
Defines if the result should be returned as a single vector
or a |
sliced |
Names can have multiple estimated nationalities ranked by
probability. This |
apikey |
Optional parameter to pass the API key. The API is free for up
to 1000 names/day. No sign up or API key needed. Yet, if more requests
would be needed, visit the
nationalize.io store and the obtained
API key can be passed through this parameter. The API can also be saved one
time through the |
meta |
|
The function automatically handles pagination (max. 10 names per API
request), missing values & duplicated values. If a name is duplicated for
the same country_id
(if the parameter has been passed), it will
handle the request as a a single name to save requests, returning the same
value for the duplicated names. To see more details about the API
documentation, visit the nationalize.io
website.
Returns the estimated nationality as the common
ISO 3166-1 alpha-2
country code. The result can be in a single character
vector form or
a data.frame
with additional information.
Please be aware about local privacy protection regulations such as GDPR when dealing with personal data.
Matthias Brenninkmeijer - https://github.com/matbmeijer
nationalize(name=c("Ben", "Maria"))
nationalize(name=c("Ben", "Maria"))
Removes saved API keys for the DemografixeR APIs (Genderize.io, Agify.io, Nationalize.io).
remove_api_key(verbose = TRUE)
remove_api_key(verbose = TRUE)
verbose |
|
Does not return any object.
Please be careful when dealing with API keys and other secrets & tokens - keep them private and do not publish them.
Matthias Brenninkmeijer - https://github.com/matbmeijer
## Not run: remove_api_key() ## End(Not run)
## Not run: remove_api_key() ## End(Not run)
Saves the all in one genderize.io, agify.io & nationalize.io API
key in the users environment. It has the advantage that it is not
necessary to explicitly publish the key in the users code. Just do it one
time and you're set. To update the key just save again and it will
overwrite the old key. To explicitly print the key, use the
get_api_key
function. To remove the key use the
remove_api_key
function.
save_api_key(key)
save_api_key(key)
key |
API key obtained from the specific website. Visit the one of the following websites to obtain an API key: |
Does save the key in the environment.
Please be careful when dealing with API keys and other secrets & tokens - keep them private and do not publish them.
Matthias Brenninkmeijer - https://github.com/matbmeijer
## Not run: save_api_key(key="__YOUR_API_KEY__") ## End(Not run)
## Not run: save_api_key(key="__YOUR_API_KEY__") ## End(Not run)
Scrapes the API websites to retrieve an updated list of supported countries for each API.
supported_countries(type)
supported_countries(type)
type |
Obligatory parameter to define the API from which to obtain the
supported countries. Must be one of the following
|
Returns a data.frame
with the supported
ISO 3166-1 alpha-2
country code, country name the number of items (names) for each country.
Please be conscious that this function directly scrapes the website, do not overuse it as it might overwhelm the server.
## Not run: supported_countries(type="genderize") ## End(Not run)
## Not run: supported_countries(type="genderize") ## End(Not run)