Introduction

In a previous vignette I demonstrated how to use choroplethrZip to get and visualize data from the US Census Bureau. choroplethrZip version 1.3.0 introduces a data.frame df_zip_demographics which contains eight statistics from the 2013 5-year American Community Survey (ACS). Additionally, it introduces a function ?get_zip_demographics which can get those same statistics from other ACS surveys.

As always, technically the regions are Zip Code Tabulated Areas (ZCTAS), not USPS ZIP Codes (link).

Data

Here are the statistics in df_zip_demographics:

library(choroplethrZip)
data(df_zip_demographics)
?df_zip_demographics

colnames(df_zip_demographics)

Visualization

Here is a program that visualizes the data for New York City as a choropleth map:

# FIPS codes for the 5 counties (boroughs) of New York City
nyc_fips = c(36005, 36047, 36061, 36081, 36085)

# print a map for each column of the demographic data.frame
for (i in 2:ncol(df_zip_demographics))
{
  # set the data and title
  df_zip_demographics$value = df_zip_demographics[,i]
  title = paste0("2013 New York City ZCTA Demographics:\n",
                 colnames(df_zip_demographics[i]))

  # print the map
  choro = zip_choropleth(df_zip_demographics, title=title, county_zoom=nyc_fips)
  print(choro)
}


arilamstein/choroplethrZip documentation built on May 10, 2019, 1:27 p.m.