Skip to contents

Get the rows of us_location_table corresponding to a given location vector and format, with repeats possible

Usage

us_location_lookup(
  location,
  location_input_format,
  location_output_format = NULL
)

location_lookup(location, location_input_format, location_output_format = NULL)

Arguments

location

vector of location values

location_input_format

format in which the location vector is coded. See to_us_location_table_column() for permitted formats.

location_output_format

Vector specifying column(s) from the output table to return. If not provided (default), return all columns. See to_us_location_table_column() for permitted strings to specify columns.

Value

A tibble with the corresponding rows of the us_location_table matching the location vector (with repeats possible) or the values of those rows for given column(s), as specified in location_output_format.

Examples


us_location_lookup(c("01", "05", "US", "05"), "code")
#> # A tibble: 4 × 3
#>   code  abbr  name         
#>   <chr> <chr> <chr>        
#> 1 01    AL    Alabama      
#> 2 05    AR    Arkansas     
#> 3 US    US    United States
#> 4 05    AR    Arkansas     

us_location_lookup(c("01", "05", "US", "05"), "code", "name")
#> # A tibble: 4 × 1
#>   name         
#>   <chr>        
#> 1 Alabama      
#> 2 Arkansas     
#> 3 United States
#> 4 Arkansas     

us_location_lookup(c("01", "05", "US", "05"), "code", c("abbr", "name"))
#> # A tibble: 4 × 2
#>   abbr  name         
#>   <chr> <chr>        
#> 1 AL    Alabama      
#> 2 AR    Arkansas     
#> 3 US    United States
#> 4 AR    Arkansas     

us_location_lookup(c("Alaska", "Hawaii"), "name", c("code", "abbr"))
#> # A tibble: 2 × 2
#>   code  abbr 
#>   <chr> <chr>
#> 1 02    AK   
#> 2 15    HI