heat_map_continuous: Create a heat map of Chicago with continuous shading.

Description Usage Arguments Value Examples

Description

Create a heat map of Chicago with continuous shading.

Usage

1
2
3
4
heat_map_continuous(regions, summary_df, regions_var, fill_var, legend_name,
  palette = NULL, low_color = "#fff5eb", high_color = "#7f2704",
  na_replace = NA, lines = "black", title = NULL, title_size = 15,
  region_labels = FALSE)

Arguments

regions

The type of region to plot. Options include: "CAs", "tracts," "districts," and "zips."

summary_df

A data frame with summary statistics by region. Should have one row for each region.

regions_var

The variable in summary_df that identifies the region. For example, if type = "CAs" a common summary_var would be "Community.Areas." In general, regions_var should be numeric (e.g. use community area numbers, not names.).

fill_var

The variable that determines color. For example, if the map shows homicides by police district, the fill_var would be the field that contains homicide totals.

legend_name

Self Explanatory. Should be a character vector of length one.

palette

The color palette. Current options are: green, blue, red, organge, and purple.

low_color

If palette is set to NULL, the low end of the color range you want to use.

high_color

The high end of your color range

na_replace

What value should replace NAs in the fill_var. This arises most commonly in maps of homicides, where regions with zero homicides are sometimes missing from df.y.

lines

Color of border lines. Default is black.

title

Title.

title_size

Title size.

region_labels

Option to add labels for CAs or districts. Default is false

Value

A map of Chicago. More specifically, an object of type "ggplot."

Examples

1
2
3
4
5
6
7
8
data(hom_14)

# Create summary table
hom_sum <- dplyr::summarise(group_by(hom_14, District), homicides = n())

h_map <- heat_map_continuous(type = "districts", summary_df = hom_sum, regions_var = "District",
                             fill_var = "homicides", legend_name = "Homicides",
                             na_replace = 0)

dmwelgus/MapChi documentation built on May 15, 2019, 9:38 a.m.