Every parse returns a gender code (M,
F or U) and a gender_confidence.
Both are estimates from how often the given names are recorded for men
and for women in U.S. Census name lists. This article shows how the
score is computed, what the confidence means, when the parser falls back
to a default, and where the census table comes from.
The examples parse a few names with parse_names() and
show the columns that matter here as a table:
library(peopleparser)
# parse names and show the columns this article is about
show <- function( x ) {
vars <- c( "name", "salutation", "first_name", "middle_name",
"suffix", "gender", "gender_confidence" )
parse_names( x )[ vars ] |> knitr::kable()
}The score
determine_gender() takes the census rows for the
given-name tokens (the first name and any middle names, never the
surname), adds up their male and female counts, and reports the larger
side:
rounded to one decimal place.
cd <- get_census_data( "LESLIE" )
cd[ , c("name", "male_value", "female_value") ] |> knitr::kable()| name | male_value | female_value |
|---|---|---|
| LESLIE | 52838 | 237654 |
determine_gender( cd )
#> [1] "F" "81.8"The confidence is the share of people with these names who have the reported gender. It runs from 50 (an even split) to 100 (only one gender recorded). It is not the probability that this particular person has that gender, which also depends on their age and on the population the record comes from.
x <- c( "JOHN SMITH", "MARY SMITH", "LESLIE SMITH",
"PAT SMITH", "CHRIS JONES", "TAYLOR SWIFT" )
show( x )| name | salutation | first_name | middle_name | suffix | gender | gender_confidence |
|---|---|---|---|---|---|---|
| JOHN SMITH | JOHN | M | 99.8 | |||
| MARY SMITH | MARY | F | 99.8 | |||
| LESLIE SMITH | LESLIE | F | 81.8 | |||
| PAT SMITH | PAT | F | 59.5 | |||
| CHRIS JONES | CHRIS | M | 94.4 | |||
| TAYLOR SWIFT | TAYLOR | F | 75.5 |
Most first names in the table are strongly gendered. Of the 53616 first names, the majority gender holds 95% or more of the count for most of them:
fn <- census.names[ census.names$first_name_value > 0, ]
share <- pmax( fn$male_value, fn$female_value ) / ( fn$male_value + fn$female_value )
# first names grouped by the share held by the majority gender
bands <-
cut(
share,
breaks = c(0.5, 0.8, 0.95, 1),
labels = c("50-80%", "80-95%", "95-100%"),
include.lowest = TRUE
)
table( bands ) |> knitr::kable( col.names = c("Majority gender share", "First names") )| Majority gender share | First names |
|---|---|
| 50-80% | 7454 |
| 80-95% | 9093 |
| 95-100% | 37069 |
Middle names count too
The counts of all given-name tokens are pooled, so the middle name can move the score. Because the counts are pooled rather than averaged, a very common name outweighs a rare one, and two names of opposite gender give a weak score whatever their order:
show( c("SARAH MAY WILSON", "JOHN MARY SMITH", "MARY JOHN SMITH") )| name | salutation | first_name | middle_name | suffix | gender | gender_confidence |
|---|---|---|---|---|---|---|
| SARAH MAY WILSON | SARAH | MAY | F | 99.8 | ||
| JOHN MARY SMITH | JOHN | MARY | M | 63.8 | ||
| MARY JOHN SMITH | MARY | JOHN | M | 63.8 |
When there is no evidence
When no given-name token is in the census (an initial, a rare name, or no given name at all), the parser falls back:
| Situation | gender |
gender_confidence |
|---|---|---|
| given names not in the census, no suffix | U |
50.0 |
given names not in the census, with JR,
SR, II, … |
M |
50.0 |
| nothing left to parse | U |
0.0 |
The suffix rule reflects that generational suffixes are almost always used by men. The 50.0 says that the call is a default, not evidence.
show( c("J SMITH", "J SMITH JR", "A J SMITH", "TSHEPO CHO", "SMITH JR") )| name | salutation | first_name | middle_name | suffix | gender | gender_confidence |
|---|---|---|---|---|---|---|
| J SMITH | J | U | 50.0 | |||
| J SMITH JR | J | JR | M | 50.0 | ||
| A J SMITH | A | J | U | 50.0 | ||
| TSHEPO CHO | TSHEPO | U | 50.0 | |||
| SMITH JR | JR | M | 50.0 |
Salutations
parse_name() does not use the salutation for gender:
MR PAT SMITH is scored from PAT alone. If you
need a salutation to override the census score, do it after parsing:
d <- parse_names( c("MR PAT SMITH", "MRS PAT SMITH", "DR PAT SMITH") )
# MR is male, MRS / MS / MISS female; any other title keeps the census score
d$gender_sal <-
ifelse( d$salutation == "MR", "M",
ifelse( d$salutation %in% c("MRS", "MS", "MISS"), "F",
d$gender ) )
d[ c("name", "salutation", "gender", "gender_confidence", "gender_sal") ] |> knitr::kable()| name | salutation | gender | gender_confidence | gender_sal |
|---|---|---|---|---|
| MR PAT SMITH | MR | F | 59.5 | M |
| MRS PAT SMITH | MRS | F | 59.5 | F |
| DR PAT SMITH | DR | F | 59.5 | F |
The nickname functions do this already: in
nickname_lookup() a gendered salutation (MR,
MRS, MS, MISS) beats the census
score. See vignette("canonical-first-names").
Using the scores
gender_confidence is returned as text. Convert it before
comparing:
d <- parse_names( c("JOHN SMITH", "PAT SMITH", "J SMITH", "CHRIS JONES") )
# confidence is text: convert it, then call anything under 80 unknown
d$gender_confidence <- as.numeric( d$gender_confidence )
d$gender_80 <- ifelse( d$gender_confidence >= 80, d$gender, "U" )
d[ c("name", "gender", "gender_confidence", "gender_80") ] |> knitr::kable()| name | gender | gender_confidence | gender_80 |
|---|---|---|---|
| JOHN SMITH | M | 99.8 | M |
| PAT SMITH | F | 59.5 | U |
| J SMITH | U | 50.0 | U |
| CHRIS JONES | M | 94.4 | M |
A threshold of 80 (what nickname_lookup() uses) keeps
most names and drops the ones that are close to even. For counts of
women and men in a population, summing the shares can be better than
counting hard calls, because it does not round every PAT to
female.
Keep in mind:
- The counts are for the whole U.S. population in 2020, children
included. Name use changes over time (
LESLIEandASHLEYwere once mostly male names;TAYLORandRILEYhave become mostly female) and across countries, so the score fits some groups better than others. - The census lists record only male and female. The scores say nothing about how people identify.
- Names missing from the list, many of them non-English given names, get no score at all.
Where the census table comes from
census.names is bundled with the package in
data/census.names.rda. It is not downloaded when the
package is installed or used. It is built by
data-raw/census_names.R from the Census Bureau’s 2020 name
release, Frequently Occurring First Names and Last Names from the
2020 Census (revised April 2026):
cn <- census.names
# how many names have a count in each role
data.frame(
rows = nrow( cn ),
male_names = sum( cn$male_value > 0 ),
female_names = sum( cn$female_value > 0 ),
first_names = sum( cn$first_name_value > 0 ),
surnames = sum( cn$last_name_value > 0 )
) |> knitr::kable( format.args = list(big.mark = ",") )| rows | male_names | female_names | first_names | surnames |
|---|---|---|---|---|
| 195,311 | 47,089 | 51,475 | 53,616 | 156,622 |
# a common surname, and the catch-all row
cn[ cn$name %in% c("SMITH", "ALL OTHER NAMES"), ] |> knitr::kable()| name | male_value | female_value | first_name_value | last_name_value |
|---|---|---|---|---|
| ALL OTHER NAMES | 7768920 | 11025786 | 18794706 | 36257637 |
| SMITH | 4102 | 897 | 4999 | 2369644 |
-
Given names and gender: every first name held by 91
or more people in the 2020 Census, with the count of people recorded
male and female.
first_name_valueismale_value + female_value. -
Surnames: every surname held by 92 or more people,
plus a catch-all
ALL OTHER NAMESrow (which no single name token matches).
Earlier table. Until November 2026 the package shipped a table built from the 1990 first-name lists (1,219 male and 4,275 female names, published as percentages and scaled to counts) and the 2010 surname file. The 2020 lists hold ten times as many given names, so far fewer names get no gender. On a sample of 9,608 Form 990 Part VII names, the 2020 table:
- matched the gender implied by an
MR,MRSorMSsalutation in 86% of cases, against 79%; - left 227 names with unknown gender, against 727;
- kept the written first word as the first name in 96.3% of plain two- and three-word names, against 95.4%.
Refreshing the table. When the Bureau publishes new
lists, update the file names in data-raw/census_names.R and
run it from the package root. It downloads the files, records their
sizes and SHA-256 hashes in data-raw/census-names-src.csv,
rebuilds the five columns, and prints a comparison with the bundled
table: size, names whose main role (first name or surname) changes, and
names whose majority gender flips. Set
CENSUS_NAMES_SAVE=TRUE to overwrite the bundled table, then
rerun the tests and compare parses before and after, since any change
moves name-order and gender results.