map_bls: choropleth mapping of BLS data

Description Usage Arguments See Also Examples

View source: R/map_bls.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
map_bls(
  map_data,
  fill_rate = NULL,
  labtitle = NULL,
  stateName = NULL,
  projection = NULL,
  lowFill = "green",
  highFill = "red",
  ...
)

Arguments

map_data

Dataframe to be used as the map's measures. Usually a result of calls to the get_bls_county() or get_bls_state() functions, but other dataframes, which include FIPS codes may be used as well.

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 ggplot2::scale_fill_gradient.

highFill

The fill color of the higher values being mapped. The default color is green, but can be changed to any color accepted by ggplot2::scale_fill_gradient.

...

additional arguments

See Also

https://cran.r-project.org/package=tigris

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## 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)

blscrapeR documentation built on Dec. 18, 2019, 1:47 a.m.