| Type: | Package |
| Title: | Classify Names by Gender, U.S. Ethnicity, and Leaf Nationality |
| Version: | 1.0.2 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Imports: | httr, RCurl, jsonlite, utils |
| RoxygenNote: | 7.3.3 |
| Suggests: | knitr, rmarkdown |
| URL: | https://github.com/lobsterbush/nomine |
| BugReports: | https://github.com/lobsterbush/nomine/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-03-28 02:09:06 UTC; f00421k |
| Author: | Charles Crabtree [aut, cre], Volha Chykina [aut], Micah Gell-Redman [aut], Christian Chacua [aut] |
| Maintainer: | Charles Crabtree <charles.crabtree@monash.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-01 08:20:02 UTC |
Classifies names based on 6 U.S. ethnicities
Description
Returns an object that classifies any inputted name(s) according to 6 different U.S. ethnicities.
Usage
get_ethnicities(x, t = NULL, warnings = FALSE)
Arguments
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. |
Value
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.
Author(s)
Charles Crabtree ccrabtr@umich.edu and Christian Chacua christian-mauricio.chacua-delgado@u-bordeaux.fr
Examples
# 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)
Classifies names based on gender
Description
Returns an object that classifies inputted names according to gender.
Usage
get_gender(given, family, api_key)
Arguments
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/ |
Value
An object that classifies inputted names according to gender.
Author(s)
Charles Crabtree ccrabtr@umich.edu
Examples
# 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)
Classifies names based on 39 leaf nationalities
Description
Returns an object that classifies inputted names according to 39 different leaf nationalities.
Usage
get_nationalities(x, t = NULL, warnings = FALSE)
Arguments
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. |
Value
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.
Author(s)
Charles Crabtree ccrabtr@umich.edu and Christian Chacua christian-mauricio.chacua-delgado@u-bordeaux.fr
Examples
# 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)