map_bls | R Documentation |
Return a ggplot object to render a choropleth map with state and/or county outlines.
The map files contain 2016 FIPS codes and can be used with any data set containing
county and state FIPS codes. They can not be used with the leaflet package but the shape files can be
downloaded from the Census website or with the tigris
package. See the "Mapping BLS Data" vignette for this package.
map_bls( map_data, fill_rate = NULL, labtitle = NULL, stateName = NULL, projection = NULL, lowFill = "green", highFill = "red", ... )
map_data |
Dataframe to be used as the map's measures. Usually a result of
calls to the |
fill_rate |
Column name from the dataframe that you want to use as a fill value, in quotes. NOTE: This argument is mandatory! |
labtitle |
The main title label for your map passed as a string. The default is no title. |
stateName |
Optional argument if you only want to map a single state or a group of selected states. The argument accepts state full state names in quotes. |
projection |
Choices of map projection are "lambert" or "mercator". By default, the function selects Lambert for county data and Mercator for single states. and Lambert for nationwide views. |
lowFill |
The fill color of the lower values being mapped. The default color is green, but can be changed to any color accepted by
|
highFill |
The fill color of the higher values being mapped. The default color is green, but can be changed to any color accepted by
|
... |
additional arguments |
A ggplot2
object based on information provided by the map_data
argument.
https://cran.r-project.org/package=tigris
## Not run: # Download the most current month unemployment statistics on a county level. df <- get_bls_county() # Map the unemployment rate by county. bls_gg <- map_bls(map_data = df, fill_rate = "unemployed_rate", labtitle = "Unemployment Rate") bls_gg # Map the unemployment rate for Florida and Alabama. df <- get_bls_county(stateName = c("Florida", "Alabama")) bls_gg <- map_bls(map_data=df, fill_rate = "unemployed_rate", stateName = c("Florida", "Alabama")) bls_gg # Downlaod state employment statistics for April 2016. df <- get_bls_state("April 2016", seasonality = TRUE) # Map the unemployment rate from data set. bls_gg <- map_bls(map_data = df, fill_rate = "unemployed_rate", labtitle = "Unemployment Rate") bls_gg ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.