Skip to contents

Joins each element of a name vector against the census.names reference table to retrieve its male, female, first-name, and last-name occurrence counts. The lookup uses a keyed binary-search join on census.names (which is keyed on name), so it stays fast even though the reference table has ~165k rows.

Usage

get_census_data(x)

Arguments

x

A character vector of name tokens (typically the output of prep_name() split on spaces). Dashes are stripped before lookup because the census data stores compound names without them.

Value

A data.table with one row per input token, keyed and sorted on ordinal (the token's original position). Columns: name, ordinal, male_value, female_value, first_name_value, last_name_value. Tokens absent from the census table get zero counts.

Examples

x <- "livingston III,  Mr. MICHAEL JOHN9"
x <- prep_name(x)
x <- strsplit(x, " ")[[1]]
get_census_data(x)
#> Key: <ordinal>
#>          name ordinal male_value female_value first_name_value last_name_value
#>        <char>   <int>      <num>        <num>            <num>           <num>
#> 1: LIVINGSTON       1          0            0                0           42103
#> 2:        III       2          0            0                0               0
#> 3:         MR       3          0            0                0               0
#> 4:    MICHAEL       4    3765401        18222          3783623           40736
#> 5:       JOHN       5    4684909        18222          4703131           33543