Package 'nomine'

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-10-01 14:25:32 UTC
Source: https://github.com/lobsterbush/nomine

Help Index


Request ethnicity probabilities from NamePrism

Description

Sends names to NamePrism and returns probabilities for its six U.S. ethnicity categories. These are name-based predictions, not self-reported identities.

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

Your NamePrism API token. You must supply one; NULL stops the call. See https://www.name-prism.com/api for more details.

warnings

If TRUE, warn when a request fails. The default 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 [email protected] and Christian Chacua [email protected]

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)

Request gender predictions from NamSor

Description

Sends given and family names to NamSor and returns its gender prediction and scale.

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

Your NamSor API key. Get one at https://namsor.app/

Value

A data frame with the input names, API URL, predicted gender and scale.

Author(s)

Charles Crabtree [email protected]

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)

Request nationality probabilities from NamePrism

Description

Sends names to NamePrism and returns probabilities for its 39 leaf nationality categories.

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

Your NamePrism API token. You must supply one; NULL stops the call. See https://www.name-prism.com/api for more details.

warnings

If TRUE, warn when a request fails. The default 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 [email protected] and Christian Chacua [email protected]

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)