addBivariateChoropleth: Add a Bivariate Choropleth to a Leaflet Map

View source: R/bivariate_choropleth.R

addBivariateChoroplethR Documentation

Add a Bivariate Choropleth to a Leaflet Map

Description

Please note this function is a work in progress and this documentation needs improving.

Usage

addBivariateChoropleth(
  map,
  map_data,
  var1_name,
  var2_name,
  ntiles = 3,
  var1_label = NA,
  var2_label = NA,
  label_arrows = TRUE,
  region_names = NA,
  add_legend = TRUE,
  paletteFunction = pals::stevens.pinkblue,
  ...
)

Arguments

map

A Leaflet map created by 'leaflet::leaflet()'.

map_data

'sf' object with geometry features and two columns of data to plot with a bivariate choropleth.

var1_name

Column name of the first variable.

var2_name

Column name of the second variable.

ntiles

Number of ntiles. 3 works well.

var1_label

Human-readable label for variable 1.

var2_label

Human-readable label for variable 2.

label_arrows

Boolean, defaults TRUE. Should we show nice arrows on the legend?

region_names

Column with region names.

add_legend

Boolean, defaults TRUE. Should we add a legend?

paletteFunction

Bivariate palette function. Defaults to 'pals::stevens.pinkblue'.

...

Other arguments passed to Leaflet.

Details

Please submit any bugs or issues on GitHub: https://github.com/chris31415926535/bivariatechoropleths

Value

A Leaflet object with a bivariate choropleth.

Examples

## Not run: 
leaflet::leaflet() %>%
  leaflet::addTiles() %>%
  bivariatechoropleths::addBivariateChoropleth(
    map_data = bivariatechoropleths::renfrew_county,
    var1_name = pop_2016,
    var2_name = median_household_income_2015,
    ntiles= 3,
    var1_label = "Population, 2016",
    var2_label = "Median Household\nIncome, 2015",
    region_name = "CSDNAME",
    weight = 1,
    fillOpacity = 0.7,
    color = "grey",
    highlightOptions = leaflet::highlightOptions(color = "orange",
                                                 weight = 2,
                                                 opacity = 1))
#'     
## End(Not run)

chris31415926535/bivariatechoropleths documentation built on April 7, 2022, 12:27 a.m.