Title: | Simplify the Creation of Choropleth Maps in R |
---|---|
Description: | Choropleths are thematic maps where geographic regions, such as states, are colored according to some metric, such as the number of people who live in that state. This package simplifies this process by 1. Providing ready-made functions for creating choropleths of common maps. 2. Providing data and API connections to interesting data sources for making choropleths. 3. Providing a framework for creating choropleths from arbitrary shapefiles. 4. Overlaying those maps over reference maps from Google Maps. |
Authors: | Ari Lamstein [aut, cre], Brian Johnson [ctb], Trulia, Inc. [cph] |
Maintainer: | Ari Lamstein <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 3.7.3 |
Built: | 2025-02-12 10:23:27 UTC |
Source: | https://github.com/cranhaven/cranhaven.r-universe.dev |
The map used comes from ?admin1.map in the choroplethrAdmin1 package. See ?get_admin_countries and ?get_admin_regions in the choroplethrAdmin1 package for help with the spelling of regions.
admin1_choropleth( country.name, df, title = "", legend = "", num_colors = 7, zoom = NULL, reference_map = FALSE )
admin1_choropleth( country.name, df, title = "", legend = "", num_colors = 7, zoom = NULL, reference_map = FALSE )
country.name |
The name of the country. Must exactly match how the country is named in the "country" column of ?admin1.regions in the choroplethrAdmin1 package. |
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 ?admin1.regions in the choroplethrAdmin1 package |
title |
An optional title for the map. |
legend |
An optional name for the legend. |
num_colors |
The number of colors on the map. A value of 1 will use a continuous scale. A value in [2, 9] will use that many colors. |
zoom |
An optional vector of regions to zoom in on. Elements of this vector must exactly match the names of regions as they appear in the "region" column of ?admin1.regions. |
reference_map |
If true, render the choropleth over a reference map from Google Maps. |
## Not run: library(choroplethrAdmin1) data(df_japan_census) head(df_japan_census) # set the value we want to map to be the 2010 population estimates df_japan_census$value=df_japan_census$pop_2010 # default map of all of japan admin1_choropleth("japan", df_japan_census, "2010 Japan Population Estimates", "Population") # zoom in on the Kansai region and use a continuous scale kansai = c("mie", "nara", "wakayama", "kyoto", "osaka", "hyogo", "shiga") admin1_choropleth("japan", df_japan_census, "2010 Japan Population Estimates", "Population", 1, kansai) admin1_choropleth("japan", df_japan_census, "2010 Japan Population Estimates", "Population", 1, kansai, reference_map = TRUE) ## End(Not run)
## Not run: library(choroplethrAdmin1) data(df_japan_census) head(df_japan_census) # set the value we want to map to be the 2010 population estimates df_japan_census$value=df_japan_census$pop_2010 # default map of all of japan admin1_choropleth("japan", df_japan_census, "2010 Japan Population Estimates", "Population") # zoom in on the Kansai region and use a continuous scale kansai = c("mie", "nara", "wakayama", "kyoto", "osaka", "hyogo", "shiga") admin1_choropleth("japan", df_japan_census, "2010 Japan Population Estimates", "Population", 1, kansai) admin1_choropleth("japan", df_japan_census, "2010 Japan Population Estimates", "Population", 1, kansai, reference_map = TRUE) ## End(Not run)
Unlike ?admin1_choropleth, the regions here can span multiple countries.
admin1_region_choropleth( df, title = "", legend = "", num_colors = 7, zoom = NULL, reference_map = FALSE )
admin1_region_choropleth( df, title = "", legend = "", num_colors = 7, zoom = NULL, reference_map = FALSE )
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 ?admin1.regions in the choroplethrAdmin1 package |
title |
An optional title for the map. |
legend |
An optional name for the legend. |
num_colors |
The number of colors on the map. A value of 1 will use a continuous scale. A value in [2, 9] will use that many colors. |
zoom |
An optional vector of regions to zoom in on. Elements of this vector must exactly match the names of regions as they appear in the "region" column of ?admin1.regions. |
reference_map |
If true, render the choropleth over a reference map from Google Maps. |
The map used comes from ?admin1.map in the choroplethrAdmin1 package. See ?get_admin_countries and ?get_admin_regions in the choroplethrAdmin1 package for help with the spelling of regions.
## Not run: library(choroplethrAdmin1) # map of continental us + southern canada data("continental_us_states") lower_canada = c("british columbia", "alberta", "saskatchewan", "manitoba", "ontario", "quebec") regions = c(lower_canada, continental_us_states) df = data.frame(region=regions, value=sample(1:length(regions))) admin1_region_choropleth(df) ## End(Not run)
## Not run: library(choroplethrAdmin1) # map of continental us + southern canada data("continental_us_states") lower_canada = c("british columbia", "alberta", "saskatchewan", "manitoba", "ontario", "quebec") regions = c(lower_canada, continental_us_states) df = data.frame(region=regions, value=sample(1:length(regions))) admin1_region_choropleth(df) ## End(Not run)
An R6 object for creating Administration Level 1 choropleths.
An R6 object for creating Administration Level 1 choropleths.
choroplethr::Choropleth
-> Admin1Choropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$clip()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$set_zoom()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
new()
Admin1Choropleth$new(country.name, user.df)
clone()
The objects of this class are cloneable with this method.
Admin1Choropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
Compare with the Admin1Choropleth object, which creates Admin 1 choropleths based on Countries. This function is useful if you want a map that spans multiple countries - Especially if it only needs to include a portion of a country.
choroplethr::Choropleth
-> Admin1RegionChoropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$clip()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$set_zoom()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
new()
Admin1RegionChoropleth$new(user.df)
clone()
The objects of this class are cloneable with this method.
Admin1RegionChoropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
Merges df1 and df2 on column named "region", and computes percentage change from df1$value to df2$value. Result is in the new "value" column, and rounded to two digits.
calculate_percent_change(df1, df2)
calculate_percent_change(df1, df2)
df1 |
A dataframe with columns named "region" and "value" |
df2 |
A dataframe with columns named "region" and "value" |
## Not run: # load median age estimates from 2010 and 2015 data(df_state_age_2010) data(df_state_age_2015) df_age_diff = calculate_percent_change(df_state_age_2010, df_state_age_2015) state_choropleth(df_age_diff, title = "Percent Change in Median Age, 2010-2015", legend = "Percent Change", num_colors = 0) ## End(Not run)
## Not run: # load median age estimates from 2010 and 2015 data(df_state_age_2010) data(df_state_age_2015) df_age_diff = calculate_percent_change(df_state_age_2010, df_state_age_2015) state_choropleth(df_age_diff, title = "Percent Change in Median Age, 2010-2015", legend = "Percent Change", num_colors = 0) ## End(Not run)
The base Choropleth object.
The base Choropleth object.
new()
Choropleth$new(map.df, user.df)
render()
Choropleth$render()
get_min_long()
Choropleth$get_min_long()
get_max_long()
Choropleth$get_max_long()
get_min_lat()
Choropleth$get_min_lat()
get_max_lat()
Choropleth$get_max_lat()
get_bounding_box()
Choropleth$get_bounding_box(long_margin_percent, lat_margin_percent)
get_x_scale()
Choropleth$get_x_scale()
get_y_scale()
Choropleth$get_y_scale()
get_reference_map()
Choropleth$get_reference_map()
get_choropleth_as_polygon()
Choropleth$get_choropleth_as_polygon(alpha)
render_with_reference_map()
Choropleth$render_with_reference_map(alpha = 0.5)
clip()
Choropleth$clip()
discretize()
Choropleth$discretize()
bind()
Choropleth$bind()
prepare_map()
Choropleth$prepare_map()
get_scale()
Choropleth$get_scale()
theme_clean()
Choropleth$theme_clean()
theme_inset()
Choropleth$theme_inset()
format_levels()
Choropleth$format_levels(x, nsep = " to ")
set_zoom()
Choropleth$set_zoom(zoom)
get_zoom()
Choropleth$get_zoom()
set_num_colors()
Choropleth$set_num_colors(num_colors)
clone()
The objects of this class are cloneable with this method.
Choropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
Given a list of choropleths, represented as ggplot2 objects
Save the individual images to the working directory with the naming convention "choropleth_1.png", "choropleth_2.png", etc.
Write a file called "animated_choropleth.html" which contains a viewer which animates them.
choroplethr_animate(choropleths)
choroplethr_animate(choropleths)
choropleths |
A list of choropleths represented as ggplot2 objects. |
Nothing. However, a variable number of files are written to the current working directory.
Ari Lamstein (R code) and Brian Johnson (JavaScript, HTML and CSS code)
## Not run: data(df_president_ts) ?df_president_ts # time series of all US presidential elections 1789-2012 # create a list of choropleths of presidential election results for each year choropleths = list() for (i in 2:(ncol(df_president_ts))) { df = df_president_ts[, c(1, i)] colnames(df) = c("region", "value") title = paste0("Presidential Election Results: ", colnames(df_president_ts)[i]) choropleths[[i-1]] = state_choropleth(df, title=title) } # set working directory and animate setwd("~/Desktop") choroplethr_animate(choropleths) ## End(Not run)
## Not run: data(df_president_ts) ?df_president_ts # time series of all US presidential elections 1789-2012 # create a list of choropleths of presidential election results for each year choropleths = list() for (i in 2:(ncol(df_president_ts))) { df = df_president_ts[, c(1, i)] colnames(df) = c("region", "value") title = paste0("Presidential Election Results: ", colnames(df_president_ts)[i]) choropleths[[i-1]] = state_choropleth(df, title=title) } # set working directory and animate setwd("~/Desktop") choroplethr_animate(choropleths) ## End(Not run)
Create a country-level choropleth using data from the World Bank's World Development Indicators (WDI)
choroplethr_wdi( code = "SP.POP.TOTL", year = 2012, title = "", num_colors = 7, zoom = NULL )
choroplethr_wdi( code = "SP.POP.TOTL", year = 2012, title = "", num_colors = 7, zoom = NULL )
code |
The WDI code to use. |
year |
The year of data to use. |
title |
A title for the map. If not specified, automatically generated to include WDI code and year. |
num_colors |
The number of colors to use on the map. A value of 1 will use a continuous scale, and a value in [2, 9] will use that many colors. |
zoom |
An optional list of countries to zoom in on. Must come from the "name" column in ?country.regions. |
A choropleth.
Uses the WDI function from the WDI package by Vincent Arel-Bundock.
## Not run: # See http://data.worldbank.org/indicator/SP.POP.TOTL choroplethr_wdi(code="SP.POP.TOTL", year=2012, title="2012 Population Estimates", num_colors=1) # See http://data.worldbank.org/indicator/SP.DYN.LE00.IN choroplethr_wdi(code="SP.DYN.LE00.IN", year=2012, title="2012 Life Expectancy Estimates") # See http://data.worldbank.org/indicator/NY.GDP.PCAP.CD choroplethr_wdi(code="NY.GDP.PCAP.CD", year=2012, title="2012 Per Capita Income") ## End(Not run)
## Not run: # See http://data.worldbank.org/indicator/SP.POP.TOTL choroplethr_wdi(code="SP.POP.TOTL", year=2012, title="2012 Population Estimates", num_colors=1) # See http://data.worldbank.org/indicator/SP.DYN.LE00.IN choroplethr_wdi(code="SP.DYN.LE00.IN", year=2012, title="2012 Life Expectancy Estimates") # See http://data.worldbank.org/indicator/NY.GDP.PCAP.CD choroplethr_wdi(code="NY.GDP.PCAP.CD", year=2012, title="2012 Per Capita Income") ## End(Not run)
Column region is how the Census Bureau refers to the geography. Note that this region is a 4-character string, and so has a leading 0 if necessary. The first two characters are the state FIPS code, and the second two characters are the district ID. States that only have 1 district (i.e. a representative "at large") have district 00. All other states start at 01.
data(congress116.regions)
data(congress116.regions)
A vector of the names of US Continental US States.
data(continental_us_states)
data(continental_us_states)
Ari Lamstein
The map used is country.map in the choroplethrMaps package. See country.regions for an object which can help you coerce your regions into the required format.
country_choropleth(df, title = "", legend = "", num_colors = 7, zoom = NULL)
country_choropleth(df, title = "", legend = "", num_colors = 7, zoom = NULL)
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 ?country.map. |
title |
An optional title for the map. |
legend |
An optional name for the legend. |
num_colors |
The number of colors to use on the map. A value of 0 uses a divergent scale (useful for visualizing negative and positive numbers), A value of 1 uses a continuous scale (useful for visualizing outliers), and a value in [2, 9] will use that many quantiles. |
zoom |
An optional vector of countries to zoom in on. Elements of this vector must exactly match the names of countries as they appear in the "region" column of ?country.regions |
# demonstrate default options data(df_pop_country) country_choropleth(df_pop_country, "2012 World Bank Populate Estimates") # demonstrate continuous scale country_choropleth(df_pop_country, "2012 World Bank Populate Estimates", num_colors=1) # demonstrate zooming country_choropleth(df_pop_country, "2012 World Bank Population Estimates", num_colors=1, zoom=c("united states of america", "canada", "mexico"))
# demonstrate default options data(df_pop_country) country_choropleth(df_pop_country, "2012 World Bank Populate Estimates") # demonstrate continuous scale country_choropleth(df_pop_country, "2012 World Bank Populate Estimates", num_colors=1) # demonstrate zooming country_choropleth(df_pop_country, "2012 World Bank Population Estimates", num_colors=1, zoom=c("united states of america", "canada", "mexico"))
An R6 object for creating country-level choropleths.
An R6 object for creating country-level choropleths.
choroplethr::Choropleth
-> CountryChoropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$clip()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$set_zoom()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
new()
CountryChoropleth$new(user.df)
clone()
The objects of this class are cloneable with this method.
CountryChoropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
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.
county_choropleth( df, title = "", legend = "", num_colors = 7, state_zoom = NULL, county_zoom = NULL, reference_map = FALSE )
county_choropleth( df, title = "", legend = "", num_colors = 7, state_zoom = NULL, county_zoom = NULL, reference_map = FALSE )
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. |
num_colors |
The number of colors to use on the map. A value of 0 uses a divergent scale (useful for visualizing negative and positive numbers), A value of 1 uses a continuous scale (useful for visualizing outliers), and a value in [2, 9] will use that many quantiles. |
state_zoom |
An optional vector of states to zoom in on. Elements of this vector must exactly match the names of states as they appear in the "region" column of ?state.regions. |
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. |
reference_map |
If true, render the choropleth over a reference map from Google Maps. |
## Not run: # default parameters data(df_pop_county) county_choropleth(df_pop_county, title = "US 2012 County Population Estimates", legend = "Population") # zoom in on california and add a reference map county_choropleth(df_pop_county, title = "California County Population Estimates", legend = "Population", state_zoom = "california", reference_map = TRUE) # continuous scale data(df_pop_county) county_choropleth(df_pop_county, title = "US 2012 County Population Estimates", legend = "Population", num_colors = 1, state_zoom = c("california", "oregon", "washington")) library(dplyr) library(choroplethrMaps) data(county.regions) # 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_choropleth(df_pop_county, title = "Population of Counties in New York City", legend = "Population", num_colors = 1, county_zoom = nyc_county_fips$region) ## End(Not run)
## Not run: # default parameters data(df_pop_county) county_choropleth(df_pop_county, title = "US 2012 County Population Estimates", legend = "Population") # zoom in on california and add a reference map county_choropleth(df_pop_county, title = "California County Population Estimates", legend = "Population", state_zoom = "california", reference_map = TRUE) # continuous scale data(df_pop_county) county_choropleth(df_pop_county, title = "US 2012 County Population Estimates", legend = "Population", num_colors = 1, state_zoom = c("california", "oregon", "washington")) library(dplyr) library(choroplethrMaps) data(county.regions) # 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_choropleth(df_pop_county, title = "Population of Counties in New York City", legend = "Population", num_colors = 1, county_zoom = nyc_county_fips$region) ## End(Not run)
Creates a US County choropleth using the US Census' American Community Survey (ACS) data. Requires the acs package to be installed, and a Census API Key to be set with the acs's api.key.install function. Census API keys can be obtained at http://www.census.gov/developers/tos/key_request.html.
county_choropleth_acs( tableId, endyear = 2011, span = 5, num_colors = 7, state_zoom = NULL, county_zoom = NULL )
county_choropleth_acs( tableId, endyear = 2011, span = 5, num_colors = 7, state_zoom = NULL, county_zoom = NULL )
tableId |
The id of an ACS table |
endyear |
The end year of the survey to use. See acs.fetch (?acs.fetch) and http://1.usa.gov/1geFSSj for details. |
span |
The span of time to use. See acs.fetch and http://1.usa.gov/1geFSSj for details. |
num_colors |
The number of colors on the map. A value of 1 will use a continuous scale. A value in [2, 9] will use that many colors. |
state_zoom |
An optional vector of states to zoom in on. Elements of this vector must exactly match the names of states as they appear in the "region" column of ?state.regions. |
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. |
A choropleth.
Uses the acs package created by Ezra Haber Glenn.
api.key.install
in the acs package which sets an Census API key for the acs library
http://factfinder2.census.gov/faces/help/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS which contains a list of all ACS surveys.
## Not run: # median income, all counties in US county_choropleth_acs("B19301") # continuous scale, zooing in on all counties in New York, New Jersey and Connecticut county_choropleth_acs("B19301", num_colors=1, state_zoom=c("new york", "new jersey", "connecticut")) # zooming in on the 5 counties (boroughs) that make up New York City library(dplyr) library(choroplethrMaps) data(county.regions) 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_choropleth_acs("B19301", num_colors=1, county_zoom=nyc_county_fips$region) ## End(Not run)
## Not run: # median income, all counties in US county_choropleth_acs("B19301") # continuous scale, zooing in on all counties in New York, New Jersey and Connecticut county_choropleth_acs("B19301", num_colors=1, state_zoom=c("new york", "new jersey", "connecticut")) # zooming in on the 5 counties (boroughs) that make up New York City library(dplyr) library(choroplethrMaps) data(county.regions) 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_choropleth_acs("B19301", num_colors=1, county_zoom=nyc_county_fips$region) ## End(Not run)
Create a county-level choropleth
Create a county-level choropleth
choroplethr::Choropleth
-> choroplethr::USAChoropleth
-> CountyChoropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
choroplethr::USAChoropleth$render()
choroplethr::USAChoropleth$render_helper()
choroplethr::USAChoropleth$render_state_outline()
choroplethr::USAChoropleth$set_zoom()
new()
CountyChoropleth$new(user.df)
clip()
CountyChoropleth$clip()
clone()
The objects of this class are cloneable with this method.
CountyChoropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
Create a county-level choropleth that zooms on counties, not states.
Create a county-level choropleth that zooms on counties, not states.
choroplethr::Choropleth
-> CountyZoomChoropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$clip()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$set_zoom()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
new()
CountyZoomChoropleth$new(user.df)
render()
CountyZoomChoropleth$render()
clone()
The objects of this class are cloneable with this method.
CountyZoomChoropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
A data.frame containing demographic statistics about the 116th Congressional Districts
data(df_congress116_demographics)
data(df_congress116_demographics)
Data comes from the 2018 5-year American Community Survey (ACS). Data generated by ?get_congressional_district_demographics
Contains the party affiliation of each member elected to the House of Representatives of the 116th Congress, along with metadata. Note that party affiliation is of who the citizens voted for, and not who is currently (July 30, 2020) serving. Currently three members have resigned since being elected, one switched party and one died. For details of how this data was compiled, please see function get_congressional_116_party_data in file get_congress_116_party_data. That file ships with this package, but is not exported, since it relies on scraping data from Wikipedia, and that web page is subject to change.
data(df_congress116_party)
data(df_congress116_party)
A data.frame containing demographic statistics for each county in the United States.
data(df_county_demographics)
data(df_county_demographics)
Data comes from the 2013 5-year American Community Survey (ACS). Data generated by ?get_county_demographics.
## Not run: library(choroplethr) data(df_county_demographics) # examine the 2013, 5-year county percent hispanic estimates as a boxplot and choropleth # the boxplot shows the distribution boxplot(df_county_demographics$percent_hispanic) # the choropleth map shows the location of the values # first set the 'value' column to be the column we want to render df_county_demographics$value = df_county_demographics$percent_hispanic county_choropleth(df_county_demographics) ## End(Not run)
## Not run: library(choroplethr) data(df_county_demographics) # examine the 2013, 5-year county percent hispanic estimates as a boxplot and choropleth # the boxplot shows the distribution boxplot(df_county_demographics$percent_hispanic) # the choropleth map shows the location of the values # first set the 'value' column to be the column we want to render df_county_demographics$value = df_county_demographics$percent_hispanic county_choropleth(df_county_demographics) ## End(Not run)
A data.frame containing basic demographic information about Japan.
data(df_japan_census)
data(df_japan_census)
Taken from the "Total Population" table from the Statistics Bureau of Japan website (https://www.stat.go.jp/english/data/nenkan/1431-02.html) on 12/1/2014.
A data.frame containing demographic statistics for each Census Tract in New York State.
data(df_ny_tract_demographics)
data(df_ny_tract_demographics)
Data comes from the 2013 5-year American Community Survey (ACS). Data generated by ?get_tract_demographics.
A data.frame containing population estimates for Countries in 2012.
data(df_pop_country)
data(df_pop_country)
Taken from the WDI package with code SP.POP.TOTL for year 2012.
A data.frame containing population estimates for US Counties in 2012.
data(df_pop_county)
data(df_pop_county)
Taken from the US American Community Survey (ACS) 5 year estimates.
A data.frame containing population estimates for all Census Tracts in New York State in 2012.
data(df_pop_ny_tract)
data(df_pop_ny_tract)
Taken from the US American Community Survey (ACS) 5 year estimates.
A data.frame containing population estimates for US States in 2012.
data(df_pop_state)
data(df_pop_state)
Taken from the US American Community Survey (ACS) 5 year estimates.
A data.frame containing election results from the 2012 US Presidential election.
data(df_president)
data(df_president)
Ari Lamstein and Richard Careaga
Taken from the FEC website on 11/21/2014.
Legend:
R = Republican
D = Democratic
DR = Democratic-Republican
W = Whig
F = Federalist
GW = George Washington
NR = National Republican
SD = Southern Democrat
PR = Progressive
AI = American Independent
SR = States' Rights
PO = Populist
CU = Constitutional Union
I = Independent
ND = Northern Democrat
KN = Know Nothing
AM = Anti-Masonic
N = Nullifier
SP = Split evenly
data(df_president_ts)
data(df_president_ts)
Taken from https://en.wikipedia.org/wiki/List_of_United_States_presidential_election_results_by_state 3/20/2014.
A data.frame containing median age estimates for US states in 2010
data(df_state_age_2010)
data(df_state_age_2010)
Taken from the US American Community Survey (ACS) 5 year estimates.
A data.frame containing median age estimates for US states in 2015
data(df_state_age_2015)
data(df_state_age_2015)
Taken from the US American Community Survey (ACS) 5 year estimates.
A data.frame containing demographic statistics for each state plus the District of Columbia.
data(df_state_demographics)
data(df_state_demographics)
Data comes from the 2013 5-year American Community Survey (ACS). Data generated by ?get_state_demographics.
## Not run: library(choroplethr) data(df_state_demographics) # examine the 2013, 5-year state percent hispanic estimates as a boxplot and choropleth # the boxplot shows the distribution boxplot(df_state_demographics$percent_hispanic) # the choropleth map shows the location of the values # first set the 'value' column to be the column we want to render df_state_demographics$value = df_state_demographics$percent_hispanic state_choropleth(df_state_demographics) ## End(Not run)
## Not run: library(choroplethr) data(df_state_demographics) # examine the 2013, 5-year state percent hispanic estimates as a boxplot and choropleth # the boxplot shows the distribution boxplot(df_state_demographics$percent_hispanic) # the choropleth map shows the location of the values # first set the 'value' column to be the column we want to render df_state_demographics$value = df_state_demographics$percent_hispanic state_choropleth(df_state_demographics) ## End(Not run)
With an optional title. Especially useful for contrasting choropleth maps both with and without a reference map underneath.
double_map(map1, map2, title = "")
double_map(map1, map2, title = "")
map1 |
The first map |
map2 |
The second map |
title |
An optional title |
The data.frame must have a column named region with a 4-character Congressional District code. Remove districts that have a district code of 98 (non-voting) or ZZ (undefined district). See https://www.census.gov/geographies/mapping-files/2019/dec/rdo/116-congressional-district-bef.html At the time this function was created, tidycensus returned 5 non-voting districts. See https://github.com/walkerke/tidycensus/issues/277
filter_to_voting_congressional_districts(df)
filter_to_voting_congressional_districts(df)
df |
A data.frame. Must have a column named region that contains character vectors of length 4. The first 2 characters should be a state FIPS code and the second 2 characters should be a Congressional District Number |
Given a map, ACS tableId, endyear and span. Prompts user for the column id if there are multiple tables. The first element of the list is a data.frame with estimates. The second element is the ACS title of the column. Requires the acs package to be installed, and a Census API Key to be set with the acs's api.key.install function. Census API keys can be obtained at http://api.census.gov/data/key_signup.html.
get_acs_data( tableId, map, endyear = 2012, span = 5, column_idx = -1, include_moe = FALSE )
get_acs_data( tableId, map, endyear = 2012, span = 5, column_idx = -1, include_moe = FALSE )
tableId |
The id of an ACS table |
map |
The map you want to use. Must be one of "state", "county" or "zip". |
endyear |
The end year of the survey to use. See acs.fetch (?acs.fetch) and http://1.usa.gov/1geFSSj for details. |
span |
The span of time to use. See acs.fetch and http://1.usa.gov/1geFSSj for details. on the same longitude and latitude map to scale. This variable is only checked when the "states" variable is equal to all 50 states. |
column_idx |
The optional column id of the table to use. If not specified and the table has multiple columns, you will be prompted for a column id. |
include_moe |
Whether to include the 90 percent margin of error. |
http://factfinder2.census.gov/faces/help/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS, which lists all ACS Surveys.
## Not run: library(Hmisc) # for cut2 # States with greater than 1M residents df = get_acs_data("B01003", "state")[[1]] # population df$value = cut2(df$value, cuts=c(0,1000000,Inf)) state_choropleth(df, title="States with a population over 1M", legend="Population") # Counties with greater than or greater than 1M residents df = get_acs_data("B01003", "county")[[1]] # population df$value = cut2(df$value, cuts=c(0,1000000,Inf)) county_choropleth(df, title="Counties with a population over 1M", legend="Population") ## End(Not run)
## Not run: library(Hmisc) # for cut2 # States with greater than 1M residents df = get_acs_data("B01003", "state")[[1]] # population df$value = cut2(df$value, cuts=c(0,1000000,Inf)) state_choropleth(df, title="States with a population over 1M", legend="Population") # Counties with greater than or greater than 1M residents df = get_acs_data("B01003", "county")[[1]] # population df$value = cut2(df$value, cuts=c(0,1000000,Inf)) county_choropleth(df, title="Counties with a population over 1M", legend="Population") ## End(Not run)
The data comes from the American Community Survey (ACS). The variables are: total population, percent White not Hispanic, Percent Black or African American not Hispanic, percent Asian not Hispanic, percent Hispanic all races, per-capita income, median rent and median age.
get_congressional_district_demographics(year = 2018, survey = "acs5")
get_congressional_district_demographics(year = 2018, survey = "acs5")
year |
The year the survey was published |
survey |
The survey. Either "acs5" or "acs1" |
The data comes from the American Community Survey (ACS). The variables are: total population, percent White not Hispanic, Percent Black or African American not Hispanic, percent Asian not Hispanic, percent Hispanic all races, per-capita income, median rent and median age.
get_county_demographics(endyear = 2013, span = 5)
get_county_demographics(endyear = 2013, span = 5)
endyear |
The end year for the survey |
span |
The span of the survey |
The choroplethr guide to Census data: http://www.arilamstein.com/open-source/choroplethr/mapping-us-census-data/
A list of all ACS Surveys: http://factfinder.census.gov/faces/affhelp/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS
## Not run: # get some demographic data on US counties from the 2010 5-year ACS df = get_county_demographics(endyear=2010, span=5) colnames(df) # analyze the percent of people who are white not hispanic # a boxplot shows the distribution boxplot(df$percent_white) # a choropleth map shows the location of the values # set the 'value' column to be the column we want to render df$value = df$percent_white county_choropleth(df) ## End(Not run)
## Not run: # get some demographic data on US counties from the 2010 5-year ACS df = get_county_demographics(endyear=2010, span=5) colnames(df) # analyze the percent of people who are white not hispanic # a boxplot shows the distribution boxplot(df$percent_white) # a choropleth map shows the location of the values # set the 'value' column to be the column we want to render df$value = df$percent_white county_choropleth(df) ## End(Not run)
The data comes from the American Community Survey (ACS). The variables are: total population, percent White not Hispanic, Percent Black or African American not Hispanic, percent Asian not Hispanic, percent Hispanic all races, per-capita income, median rent and median age.
get_state_demographics(endyear = 2013, span = 5)
get_state_demographics(endyear = 2013, span = 5)
endyear |
The end year for the survey |
span |
The span of the survey |
The choroplethr guide to Census data: http://www.arilamstein.com/open-source/choroplethr/mapping-us-census-data/
A list of all ACS Surveys: http://factfinder.census.gov/faces/affhelp/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS
## Not run: # get some demographic data on US states from the 2010 5-year ACS df = get_state_demographics(endyear=2010, span=5) colnames(df) # analyze the percent of people who are white not hispanic # a boxplot shows the distribution boxplot(df$percent_white) # a choropleth map shows the location of the values # set the 'value' column to be the column we want to render df$value = df$percent_white state_choropleth(df) ## End(Not run)
## Not run: # get some demographic data on US states from the 2010 5-year ACS df = get_state_demographics(endyear=2010, span=5) colnames(df) # analyze the percent of people who are white not hispanic # a boxplot shows the distribution boxplot(df$percent_white) # a choropleth map shows the location of the values # set the 'value' column to be the column we want to render df$value = df$percent_white state_choropleth(df) ## End(Not run)
The data comes from the American Community Survey (ACS). The variables are: total population, percent White not Hispanic, Percent Black or African American not Hispanic, percent Asian not Hispanic, percent Hispanic all races, per-capita income, median rent and median age.
get_tract_demographics( state_name, county_fips = NULL, endyear = 2013, span = 5 )
get_tract_demographics( state_name, county_fips = NULL, endyear = 2013, span = 5 )
state_name |
The name of the state. See ?state.regions for proper spelling and capitalization. |
county_fips |
An optional vector of county fips codes within the state. Useful to set because getting data on all tracts can be slow. |
endyear |
The end year for the survey |
span |
The span of the survey |
The choroplethr guide to Census data: http://www.arilamstein.com/open-source/choroplethr/mapping-us-census-data/
A list of all ACS Surveys: http://factfinder.census.gov/faces/affhelp/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS
The map returned is exactly the same map which tract_choropleth uses. It is downloaded using the "tracts" function in the tigris package, and then it is modified for use with choroplethr.
get_tract_map(state_name)
get_tract_map(state_name)
state_name |
The name of the state. See ?state.regions for proper spelling and capitalization. |
The map used is state.map in the package choroplethrMaps. See state.regions in the choroplethrMaps package for a data.frame that can help you coerce your regions into the required format.
state_choropleth( df, title = "", legend = "", num_colors = 7, zoom = NULL, reference_map = FALSE )
state_choropleth( df, title = "", legend = "", num_colors = 7, zoom = NULL, reference_map = FALSE )
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 state.map. |
title |
An optional title for the map. |
legend |
An optional name for the legend. |
num_colors |
The number of colors to use on the map. A value of 0 uses a divergent scale (useful for visualizing negative and positive numbers), A value of 1 uses a continuous scale (useful for visualizing outliers), and a value in [2, 9] will use that many quantiles. |
zoom |
An optional vector of states to zoom in on. Elements of this vector must exactly match the names of states as they appear in the "region" column of ?state.regions. |
reference_map |
If true, render the choropleth over a reference map from Google Maps. |
## Not run: # default parameters data(df_pop_state) state_choropleth(df_pop_state, title = "US 2012 State Population Estimates", legend = "Population") # choropleth over reference map of continental usa data(continental_us_states) state_choropleth(df_pop_state, title = "US 2012 State Population Estimates", legend = "Population", zoom = continental_us_states, reference_map = TRUE) # continuous scale and zoom data(df_pop_state) state_choropleth(df_pop_state, title = "US 2012 State Population Estimates", legend = "Population", num_colors = 1, zoom = c("california", "oregon", "washington")) # demonstrate user creating their own discretization of the input # demonstrate how choroplethr handles character and factor values data(df_pop_state) df_pop_state$str = "" for (i in 1:nrow(df_pop_state)) { if (df_pop_state[i,"value"] < 1000000) { df_pop_state[i,"str"] = "< 1M" } else { df_pop_state[i,"str"] = "> 1M" } } df_pop_state$value = df_pop_state$str state_choropleth(df_pop_state, title = "Which states have less than 1M people?") ## End(Not run)
## Not run: # default parameters data(df_pop_state) state_choropleth(df_pop_state, title = "US 2012 State Population Estimates", legend = "Population") # choropleth over reference map of continental usa data(continental_us_states) state_choropleth(df_pop_state, title = "US 2012 State Population Estimates", legend = "Population", zoom = continental_us_states, reference_map = TRUE) # continuous scale and zoom data(df_pop_state) state_choropleth(df_pop_state, title = "US 2012 State Population Estimates", legend = "Population", num_colors = 1, zoom = c("california", "oregon", "washington")) # demonstrate user creating their own discretization of the input # demonstrate how choroplethr handles character and factor values data(df_pop_state) df_pop_state$str = "" for (i in 1:nrow(df_pop_state)) { if (df_pop_state[i,"value"] < 1000000) { df_pop_state[i,"str"] = "< 1M" } else { df_pop_state[i,"str"] = "> 1M" } } df_pop_state$value = df_pop_state$str state_choropleth(df_pop_state, title = "Which states have less than 1M people?") ## End(Not run)
Creates a choropleth of US States using the US Census' American Community Survey (ACS) data. Requires the acs package to be installed, and a Census API Key to be set with the acs's api.key.install function. Census API keys can be obtained at http://www.census.gov/developers/tos/key_request.html.
state_choropleth_acs( tableId, endyear = 2011, span = 5, num_colors = 7, zoom = NULL )
state_choropleth_acs( tableId, endyear = 2011, span = 5, num_colors = 7, zoom = NULL )
tableId |
The id of an ACS table |
endyear |
The end year of the survey to use. See acs.fetch (?acs.fetch) and http://1.usa.gov/1geFSSj for details. |
span |
The span of time to use. See acs.fetch and http://1.usa.gov/1geFSSj for details. |
num_colors |
The number of colors on the map. A value of 1 will use a continuous scale. A value in [2, 9] will use that many colors. |
zoom |
An optional list of states to zoom in on. Must come from the "name" column in ?state.regions. |
A choropleth.
Uses the acs package created by Ezra Haber Glenn.
api.key.install
in the acs package which sets an Census API key for the acs library
http://factfinder2.census.gov/faces/help/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS which contains a list of all ACS surveys.
## Not run: # median income, default parameters state_choropleth_acs("B19301") # continuous scale, zooming in on New York, New Jersey and Connecticut state_choropleth_acs("B19301", num_colors=1, zoom=c("new york", "new jersey", "connecticut")) ## End(Not run)
## Not run: # median income, default parameters state_choropleth_acs("B19301") # continuous scale, zooming in on New York, New Jersey and Connecticut state_choropleth_acs("B19301", num_colors=1, zoom=c("new york", "new jersey", "connecticut")) ## End(Not run)
Create a state-level choropleth
Create a state-level choropleth
choroplethr::Choropleth
-> choroplethr::USAChoropleth
-> StateChoropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$clip()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
choroplethr::USAChoropleth$render_helper()
choroplethr::USAChoropleth$render_state_outline()
choroplethr::USAChoropleth$set_zoom()
new()
StateChoropleth$new(user.df)
render()
StateChoropleth$render()
clone()
The objects of this class are cloneable with this method.
StateChoropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
Create a choropleth of Census Tracts in a particular state.
tract_choropleth( df, state_name, title = "", legend = "", num_colors = 7, tract_zoom = NULL, county_zoom = NULL, reference_map = FALSE )
tract_choropleth( df, state_name, title = "", legend = "", num_colors = 7, tract_zoom = NULL, county_zoom = NULL, reference_map = FALSE )
df |
A data.frame with a column named "region" and a column named "value". |
state_name |
The name of the state. See ?state.regions for proper spelling and capitalization. |
title |
An optional title for the map. |
legend |
An optional name for the legend. |
num_colors |
The number of colors to use on the map. A value of 0 uses a divergent scale (useful for visualizing negative and positive numbers), A value of 1 uses a continuous scale (useful for visualizing outliers), and a value in [2, 9] will use that many quantiles. |
tract_zoom |
An optional vector of tracts to zoom in on. Elements of this vector must exactly match the names of tracts as they appear in the "region" column of the object returned from "get_tract_map". |
county_zoom |
An optional vector of county FIPS codes to zoom in on. Elements of this vector must exactly match the names of counties as they appear in the "county.fips.numeric" column of the object returned from "get_tract_map". |
reference_map |
If true, render the choropleth over a reference map from Google Maps. |
https://www.census.gov/data/academy/data-gems/2018/tract.html for more information on Census Tracts
An R6 object for creating choropleths of Census Tracts.
An R6 object for creating choropleths of Census Tracts.
choroplethr::Choropleth
-> TractChoropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$clip()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$set_zoom()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
new()
TractChoropleth$new(state_name, user.df)
set_zoom_tract()
TractChoropleth$set_zoom_tract(county_zoom, tract_zoom)
clone()
The objects of this class are cloneable with this method.
TractChoropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
Normal choropleth that draws Alaska and Hawaii as insets. In addition to a columns named "region" and "value", also requires a column named "state".
Normal choropleth that draws Alaska and Hawaii as insets. In addition to a columns named "region" and "value", also requires a column named "state".
choroplethr::Choropleth
-> USAChoropleth
choroplethr::Choropleth$bind()
choroplethr::Choropleth$clip()
choroplethr::Choropleth$discretize()
choroplethr::Choropleth$format_levels()
choroplethr::Choropleth$get_bounding_box()
choroplethr::Choropleth$get_choropleth_as_polygon()
choroplethr::Choropleth$get_max_lat()
choroplethr::Choropleth$get_max_long()
choroplethr::Choropleth$get_min_lat()
choroplethr::Choropleth$get_min_long()
choroplethr::Choropleth$get_reference_map()
choroplethr::Choropleth$get_scale()
choroplethr::Choropleth$get_x_scale()
choroplethr::Choropleth$get_y_scale()
choroplethr::Choropleth$get_zoom()
choroplethr::Choropleth$prepare_map()
choroplethr::Choropleth$render_with_reference_map()
choroplethr::Choropleth$set_num_colors()
choroplethr::Choropleth$theme_clean()
choroplethr::Choropleth$theme_inset()
new()
USAChoropleth$new(map.df, user.df)
render()
USAChoropleth$render()
render_helper()
USAChoropleth$render_helper(choropleth.df, scale_name, theme)
render_state_outline()
USAChoropleth$render_state_outline(states)
set_zoom()
USAChoropleth$set_zoom(zoom)
clone()
The objects of this class are cloneable with this method.
USAChoropleth$clone(deep = FALSE)
deep
Whether to make a deep clone.
Requires a data.frame with specific column names. In practice, the data.frame is expected to come from a function like ?get_congressional_districts and then merged with a data.frame that has column "party".
visualize_df_by_race_ethnicity_party(df)
visualize_df_by_race_ethnicity_party(df)
df |
A data.frame with columns "party", "percent_white", "percent_black", "percent_asian", "percent_hispanic" |
data("df_congress116_demographics") data("df_congress116_party") df = merge(df_congress116_demographics, df_congress116_party) # Race and Ethnicity of the 116th Congressional Districts using data from # the 2018 5-year American Community Survey visualize_df_by_race_ethnicity_party(df)
data("df_congress116_demographics") data("df_congress116_party") df = merge(df_congress116_demographics, df_congress116_party) # Race and Ethnicity of the 116th Congressional Districts using data from # the 2018 5-year American Community Survey visualize_df_by_race_ethnicity_party(df)