Runs a query against the CensusMapper API to retrieve region data with names matching specific queries. Users can optionally specify the target geography level (e.g. level = 'CMA', level = 'CSD', etc.). Alternatively, calling explore_census_vectors() will launch the interactive region selection tool on the Censusmapper site in a new web page or tab.

search_census_regions(searchterm, dataset, level = NA, ...)

Arguments

searchterm

The term to search for e.g. "Victoria". Search terms are case insensitive. If unable to find a given search term, this function will suggest the correct spelling to use when possible.

dataset

The dataset to query for available regions, e.g. "CA16".

level

One of NA, 'C', 'PR', 'CMA', 'CD', or 'CSD'. If specified, only return variables of specified `level`.

...

Further arguments passed on to list_census_regions.

Examples

search_census_regions('Victoria', 'CA16')
#> Reading regions list from local cache.
#> # A tibble: 11 × 8
#>    region  name              level    pop municipal_status CMA_UID CD_UID PR_UID
#>    <chr>   <chr>             <chr>  <int> <chr>            <chr>   <chr>  <chr> 
#>  1 59935   Victoria          CMA   367770 B                NA      NA     59    
#>  2 1312    Victoria          CD     18617 CT               NA      NA     13    
#>  3 1218    Victoria          CD      7089 CTY              NA      NA     12    
#>  4 5917034 Victoria          CSD    85792 CY               59935   5917   59    
#>  5 2439062 Victoriaville     CSD    46130 V                24440   2439   24    
#>  6 1218001 Victoria, Subd. B CSD     3985 SC               NA      1218   12    
#>  7 1218006 Victoria, Subd. A CSD     2567 SC               NA      1218   12    
#>  8 1001365 Victoria          CSD     1800 T                NA      1001   10    
#>  9 4608042 Victoria          CSD     1514 RM               NA      4608   46    
#> 10 4601078 Victoria Beach    CSD      398 RM               NA      4601   46    
#> 11 1102032 Victoria          CSD       74 COM              NA      1102   11    

if (FALSE) {
# This will return a warning that no match was found, but will suggest similar named regions.
search_census_regions('Victorea', 'CA16')

# This will limit region results to only include CMA level regions
search_census_regions('Victoria', 'CA16', level = "CMA")
}