county_zoom_choropleth: Create a choropleth of USA Counties, with sensible defaults,...

Description Usage Arguments Examples

Description

The map used is county.map in the choroplethrMaps package. See country.regions in the choroplethrMaps package for an object which can help you coerce your regions into the required format. If you zoom in on a single county, only an outline of the county is shown.

Usage

1
2
county_zoom_choropleth(df, title = "", legend = "", buckets = 7,
  zoom = NULL)

Arguments

df

A data.frame with a column named "region" and a column named "value". Elements in the "region" column must exactly match how regions are named in the "region" column in county.map.

title

An optional title for the map.

legend

An optional name for the legend. Ignored if zooming in on a single county.

buckets

The number of equally sized buckets to places the values in. A value of 1 will use a continuous scale, and a value in [2, 9] will use that many buckets. Ignored if zooming in on a single county.

zoom

An optional vector of counties to zoom in on. Elements of this vector must exactly match the names of counties as they appear in the "region" column of ?county.regions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 

library(choroplethrMaps)
data(county.regions)

library(dplyr)

# show the population of the 5 counties (boroughs) that make up New York City
nyc_county_names=c("kings", "bronx", "new york", "queens", "richmond")
nyc_county_fips = county.regions %>%
  filter(state.name=="new york" & county.name %in% nyc_county_names) %>%
  select(region)
county_zoom_choropleth(df_pop_county,
                       title="Population of Counties in New York City",
                       legend="Population",
                       buckets=1,
                       zoom=nyc_county_fips$region)

# zooming in on a single county shows just an outline.
county_zoom_choropleth(df_pop_county,
                       title="Zoom of Manhattan",
                       zoom=36061) # manhattan

# population of the 9 counties in the san francisco bay area
bay_area_county_names = c("alameda", "contra costa", "marin", "napa", "san francisco",
                          "san mateo", "santa clara", "solano", "sonoma")
bay_area_county_fips = county.regions %>%
  filter(state.name=="california" & county.name %in% bay_area_county_names) %>%
  select(region)
county_zoom_choropleth(df_pop_county,
                       title="Population of Counties in the San Francisco Bay Area",
                       legend="Population",
                       buckets=1,
                       zoom=bay_area_county_fips$region)

## End(Not run)

trulia/choroplethr documentation built on June 1, 2019, 1:52 a.m.