Skip to contents

This function uses fuzzy matching to help identify tables from the census which contain variables of interest. Matched table codes are printed out, along with the Census-provided table description, the parsed variable names, and example table cells. The website https://censusreporter.org/ may also be useful in finding variables.

Usage

cens_find(tables, ..., show = 4)

cens_find_dec(..., show = 2)

cens_find_acs(..., show = 4)

Arguments

tables

A list of cens_table objects, such as is produced by cens_parse_tables().

...

Variables to look for. These can be length-1 character vectors, or, for convenience, can be left unquoted (see examples).

show

How many matching tables to show. Increase this to show more possible matches, at the cost of more output. Negative values will be converted to positive but will suppress any printing.

Value

The codes for the top show tables, invisibly if show is positive.

Examples

cens_find_dec("sex", "age")
#> 
#> ── Top 2 matching tables ───────────────────────────────────────────────────────
#> 
#>  P12  - SEX BY AGE
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>sex
#>age
#>race_ethnicity
#> Example values:
#> • male / 20 years / two or more races
#> • male / 18 and 19 years / black or african american alone
#> • male / 75 to 79 years / white alone, not hispanic or latino
#> 
#>  PCT12  - SEX BY AGE
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>sex
#>age
#>race_ethnicity
#> Example values:
#> • female / 58 years / some other race alone
#> • female / 3 years / white alone
#> • male / 89 years / two or more races, not hispanic or latino
cens_find(tables_sf1, "sex", "age") # same as above
#> 
#> ── Top 4 matching tables ───────────────────────────────────────────────────────
#> 
#>  P12  - SEX BY AGE
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>sex
#>age
#>race_ethnicity
#> Example values:
#> • male / 20 years / some other race alone
#> • male / 50 to 54 years / asian alone
#> • male / 50 to 54 years / some other race alone
#> 
#>  PCT12  - SEX BY AGE
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>sex
#>age
#>race_ethnicity
#> Example values:
#> • female / 70 years / asian alone
#> • female / 7 years / white alone, not hispanic or latino
#> • female / 2 years / asian alone, not hispanic or latino
#> 
#>  PCO1  - GROUP QUARTERS POPULATION BY SEX BY AGE
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>sex
#>age
#> Example values:
#> • male / under 5 years
#> • female / under 5 years
#> • female / 85 years and over
#> 
#>  P14  - SEX BY AGE FOR THE POPULATION UNDER 20 YEARS
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>sex
#>age_for_the_population_under_20_years
#> Example values:
#> • male / 1 year
#> • male / 16 years
#> • female / 15 years
cens_find_dec(tenure, race)
#> 
#> ── Top 2 matching tables ───────────────────────────────────────────────────────
#> 
#>  H14  - TENURE BY RACE OF HOUSEHOLDER
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>tenure
#>race_of_householder
#> Example values:
#> • renter occupied / householder who is american indian and alaska native alone
#> • renter occupied / householder who is some other race alone
#> • owner occupied / householder who is black or african american alone
#> 
#>  H16  - TENURE BY HOUSEHOLD SIZE
#> Surveys / Files:
#>  Decennial / Summary File 1
#> Parsed variables:
#>tenure
#>household_size
#>race_ethnicity
#> Example values:
#> • owner occupied / 5-person household / white alone householder
#> • renter occupied / 4-person household / asian alone householder
#> • owner occupied / 4-person household / black or african american alone
#> householder
cens_find_acs("income", "sex", show=3)
#> 
#> ── Top 3 matching tables ───────────────────────────────────────────────────────
#> 
#>  B17008  - AGGREGATE INCOME DEFICIT (DOLLARS) IN THE PAST 12 MONTHS OF
#> UNRELATED INDIVIDUALS BY SEX
#> Surveys / Files:
#>  ACS / 1-year Detailed
#>  ACS / 5-year Detailed
#> Parsed variables:
#>sex
#> Example values:
#> • female (dollars)
#> • total
#> • male (dollars)
#> 
#>  B19216  - AGGREGATE NONFAMILY HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019
#> INFLATION-ADJUSTED DOLLARS) BY SEX OF HOUSEHOLDER BY LIVING ALONE BY AGE OF
#> HOUSEHOLDER
#> Surveys / Files:
#>  ACS / 1-year Detailed
#>  ACS / 5-year Detailed
#> Parsed variables:
#>sex_of_householder
#>living_alone
#>age_of_householder
#> Example values:
#> • male householder (dollars) / total / total
#> • female householder (dollars) / living alone (dollars) / total
#> • female householder (dollars) / not living alone (dollars) / householder 65
#> years and over (dollars)
#> 
#>  B21004  - MEDIAN INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED
#> DOLLARS) BY VETERAN STATUS BY SEX FOR THE CIVILIAN POPULATION 18 YEARS AND OVER
#> WITH INCOME
#> Surveys / Files:
#>  ACS / 1-year Detailed
#>  ACS / 5-year Detailed
#> Parsed variables:
#>veteran_status
#>sex_for_the_civilian_population_18_years_over_with_income
#> Example values:
#> • total / total
#> • nonveteran / male
#> • nonveteran / female
cens_find_acs("heath care", show=-1)
#> [1] "B27009"