| Title: | Classify Names by Gender, U.S. Ethnicity, and Leaf Nationality |
|---|---|
| Description: | Functions to use the 'NamePrism' API <https://www.name-prism.com/api> or 'NamSor' API v2 <https://namsor.app/> for classifying names based on gender, 6 U.S. ethnicities, or 39 leaf nationalities. Updated to work with current API endpoints. |
| Authors: | Charles Crabtree [aut, cre], Volha Chykina [aut], Micah Gell-Redman [aut], Christian Chacua [aut] |
| Maintainer: | Charles Crabtree <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.2 |
| Built: | 2026-07-04 21:58:34 UTC |
| Source: | https://github.com/cran/nomine |
Returns an object that classifies any inputted name(s) according to 6 different U.S. ethnicities.
get_ethnicities(x, t = NULL, warnings = FALSE)get_ethnicities(x, t = NULL, warnings = FALSE)
x |
A vector of names, in the form "First_name Last_name". If there are multiple segments separated by white spaces, only the first and the last segments are taken into account. |
t |
A string with the API access token. The default value is NULL, although you must set your own token. A Name-Prism API token can be obtained for research purposes to overcome the limit of anonymous API use. Please visit https://www.name-prism.com/api for more details. |
warnings |
Logical. If TRUE, then a warning message will be displayed when a name cannot be analyzed. The default value is FALSE. |
A data frame of dimensions length(x)*9, with the probability of belonging to each of the 6 different U.S. ethnicities. Errors (e.g. connection is interrupted, invalid tokens) are handled as NA.
Charles Crabtree [email protected] and Christian Chacua [email protected]
# Prepare input vector of names x <- c("Charles Crabtree", "Volha Chykina", "Christian Chacua", "Christian Mauricio Chacua") # Expected output columns expected_cols <- c("input", "encoded_name", "url", "2PRACE", "Hispanic", "API", "Black", "AIAN", "White") print(expected_cols) ## Not run: # Using the API token (you should get your own token) y <- get_ethnicities(x, t = "YOUR_NAMEPRISM_TOKEN", warnings = FALSE) y # "Christian Chacua" and "Christian Mauricio Chacua" have the same # probabilities as "Mauricio" is not taken into account. ## End(Not run)# Prepare input vector of names x <- c("Charles Crabtree", "Volha Chykina", "Christian Chacua", "Christian Mauricio Chacua") # Expected output columns expected_cols <- c("input", "encoded_name", "url", "2PRACE", "Hispanic", "API", "Black", "AIAN", "White") print(expected_cols) ## Not run: # Using the API token (you should get your own token) y <- get_ethnicities(x, t = "YOUR_NAMEPRISM_TOKEN", warnings = FALSE) y # "Christian Chacua" and "Christian Mauricio Chacua" have the same # probabilities as "Mauricio" is not taken into account. ## End(Not run)
Returns an object that classifies inputted names according to gender.
get_gender(given, family, api_key)get_gender(given, family, api_key)
given |
A vector of given names (i.e. first names). |
family |
A vector of family names (i.e. surnames or last names). |
api_key |
A NameSor API Key. This is typically a long string of mixed-case letters and numbers. Get yours at https://namsor.app/ |
An object that classifies inputted names according to gender.
Charles Crabtree [email protected]
# Prepare input vectors first_name <- c("Volha", "Charles", "Donald") last_name <- c("Chykina", "Crabtree", "Duck") # Expected output columns expected_cols <- c("id", "first_name", "last_name", "api_url", "scale", "gender") print(expected_cols) ## Not run: # Note: the vectors of first and last names should be the same length. key <- "YOUR_NAMSOR_API_KEY" y <- get_gender(first_name, last_name, key) y ## End(Not run)# Prepare input vectors first_name <- c("Volha", "Charles", "Donald") last_name <- c("Chykina", "Crabtree", "Duck") # Expected output columns expected_cols <- c("id", "first_name", "last_name", "api_url", "scale", "gender") print(expected_cols) ## Not run: # Note: the vectors of first and last names should be the same length. key <- "YOUR_NAMSOR_API_KEY" y <- get_gender(first_name, last_name, key) y ## End(Not run)
Returns an object that classifies inputted names according to 39 different leaf nationalities.
get_nationalities(x, t = NULL, warnings = FALSE)get_nationalities(x, t = NULL, warnings = FALSE)
x |
A vector of names, in the form "First_name Last_name". If there are multiple segments separated by white spaces, only the first and the last segments are taken into account. |
t |
A string with the API access token. The default value is NULL, although you must set your own token. A Name-Prism API token can be obtained for research purposes to overcome the limit of anonymous API use. Please visit https://www.name-prism.com/api for more details. |
warnings |
Logical. If TRUE, then a warning message will be displayed when a name cannot be analyzed. The default value is FALSE. |
A data frame of dimensions length(x)*42, with the probability of belonging to each of the 39 different leaf CEL groups of the Name-Prism taxonomy (see https://www.name-prism.com/about). Errors (e.g. connection is interrupted, invalid tokens) are handled as NA.
Charles Crabtree [email protected] and Christian Chacua [email protected]
# Prepare input vector of names x <- c("Charles Crabtree", "Volha Chykina", "Christian Chacua", "Christian Mauricio Chacua") # Expected output columns (3 metadata + 39 leaf nationalities) n_output_cols <- 42L print(n_output_cols) ## Not run: # Using the API token (you should get your own token) y <- get_nationalities(x, t = "YOUR_NAMEPRISM_TOKEN", warnings = FALSE) y # "Christian Chacua" and "Christian Mauricio Chacua" have the same # probabilities as "Mauricio" is not taken into account. ## End(Not run)# Prepare input vector of names x <- c("Charles Crabtree", "Volha Chykina", "Christian Chacua", "Christian Mauricio Chacua") # Expected output columns (3 metadata + 39 leaf nationalities) n_output_cols <- 42L print(n_output_cols) ## Not run: # Using the API token (you should get your own token) y <- get_nationalities(x, t = "YOUR_NAMEPRISM_TOKEN", warnings = FALSE) y # "Christian Chacua" and "Christian Mauricio Chacua" have the same # probabilities as "Mauricio" is not taken into account. ## End(Not run)