earl 2015 - mapping census data in rfiles.meetup.com/1406240/Mapping Census Data.pdf · earl 2015 - mapping census data in r.key Created Date: 10/17/2015 4:49:18 PM ...
Post on 19-Aug-2020
0 Views
Preview:
Transcript
Free course: AriLamstein.com/free-course
Mapping Census Data in R
Ari LamsteinAriLamstein.comLamstein Consulting LLC
Getting Started❖ Choropleth Maps
❖ “choroplethr” package
❖ Any shapefile, any data
❖ States, Counties, ZIP Codes
❖ American Community Survey (ACS)
❖ Estimates
❖ acs package
❖ Exploratory Data Analysis
Package Basics
Geography Function Package Location Sample Data Zoom
State state_choropleth choroplethr, choroplethrMaps CRAN
df_pop_state,df_state_demographics state
County county_choroplethchoroplethr,
choroplethrMaps CRANdf_pop_county,
df_county_demographics state, county
ZIP (ZCTA) zip_choropleth choroplethrZip github df_pop_zip, df_zip_demographics
state, county, zip, msa
Mapmaking: Basics
library(choroplethr)library(choroplethrMaps)
data(df_pop_state)state_choropleth(df_pop_state, title = "2012 State Population Estimates", legend = "Population")
state_choropleth(df_pop_state, title = "2012 State Population Estimates", legend = "Population", num_colors = 1)
data(df_pop_county)
county_choropleth(df_pop_county, title = "2012 County Population Estimates", legend = "Population")
county_choropleth(df_pop_county, title = "2012 County Population Estimates", legend = "Population", num_colors = 1)
Demographics: Basics
data(df_county_demographics)
df_county_demographics$value = df_county_demographics$percent_whitecounty_choropleth(df_county_demographics,
title = "2013 County Percent White Estimates", legend = "Percent White")
df_county_demographics$value = df_county_demographics$percent_white
county_choropleth(df_county_demographics, title = "2013 County Percent White Estimates", legend = "Percent White", num_colors = 1)
df_county_demographics$value = df_county_demographics$percent_hispanic
county_choropleth(df_county_demographics, title = "2013 County Percent Hispanic Estimates",
legend = "Percent Hispanic”)
df_county_demographics$value = df_county_demographics$percent_hispanic
county_choropleth(df_county_demographics, title = "2013 County Percent Hispanic Estimates",
legend = "Percent Hispanic”, num_colors = 1)
df_county_demographics$value = df_county_demographics$percent_black
county_choropleth(df_county_demographics, title = "2013 County Percent Black Estimates", legend = "Percent Black")
df_county_demographics$value = df_county_demographics$percent_black
county_choropleth(df_county_demographics, title = "2013 County Percent Black Estimates", legend = "Percent Black”,
num_colors = 1)
df_county_demographics$value = df_county_demographics$per_capita_income
county_choropleth(df_county_demographics, title = "2013 County Income Estimates",
legend = “Per Capita Income")
df_county_demographics$value = df_county_demographics$per_capita_income
county_choropleth(df_county_demographics, title = "2013 County Income Estimates",
legend = “Per Capita Income”, num_colors = 1)
Customization
Zoomdf_county_demographics$value = df_county_demographics$median_rent
county_choropleth(df_county_demographics, title = "2013 California County Rent", legend = "Dollars", state_zoom = "california")
Reference Mapdf_county_demographics$value = df_county_demographics$median_rent
county_choropleth(df_county_demographics, title = "2013 California County Rent", legend = "Dollars", state_zoom = "california", reference_map = TRUE)
Case Study
How has North Dakota changed?
❖ Wrote Following Up on News Stories with Choroplethr and R
❖ Guest blog post in Revolution Analytics blog, 8/25/15
❖ Accessing historic data is easy
❖ Calculated percent change
Accessing Historic Data> df = get_state_demographics(endyear=2013, span=5)
> colnames(df)[1] "region" "total_population" [3] "percent_white" "percent_black" [5] "percent_asian" "percent_hispanic" [7] "per_capita_income" "median_rent" [9] "median_age"
Conclusion
❖ Census data is
❖ powerful and relevant
❖ easy to access and map with choroplethr
❖ Free course: arilamstein.com/free-course
❖ Contact: arilamstein.com/contact
top related