Predict ethnicity either by last names or both first and last names. This is the default and recommended method for prediction.

predict_ethnicity(
  firstnames = NULL,
  lastnames = NULL,
  method = "fullname",
  threads = 0,
  na.rm = FALSE
)

Arguments

firstnames

A character vector of first names. Default to NULL. Only use this if you are using 'method' = 'fullname'.

lastnames

A character vector of last names. Default to NULL. Use this in both 'fullname' and 'lastname' methods.

method

"fullname" or "lastname". Inference method to choose from.

threads

single integer. Number of threads to use for multi-threading.

na.rm

TRUE or FALSE (bool). If TRUE, then the NAs will be removed; if FALSE, then return error if there is NA in the arguments.

Value

data.frame with probability of being each ethnic group and the predicted group (one with highest probability)

Examples

predict_ethnicity(firstnames = "Alan", lastnames = "Turing")
#>   firstname lastname prob_asian prob_black prob_hispanic prob_white  race
#> 1      Alan   Turing 0.02842531  0.2051059    0.02074103  0.7457278 white