knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of leaflethex is to create hexbin layers that can be added to plots made with the leaflet package.
This is a work in progress and is not yet a functional R package. Stay tuned!
You can install the released version of leaflethex from CRAN with:
install.packages("leaflethex")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("rpruim/leaflethex")
This is a basic example which shows you how to add the hexbin layer to your leaflet map:
library(leaflethex) df = tibble( lat = rnorm(100), lng = rnorm(100) ) map <- leaflet::leaflet(df) %>% leaflet::addTiles() %>% leaflethex::addHexbin( radius = 19, lowEndColor = "yellow", highEndColor="red") map
data
- data frame or tibble - alternate data to use for this hexbin instead of default map dataradius
- numeric - choose the base size for the hexagonsopacity
- decimal - between 0.0 and 1.0 - choose the percent of opacity for the hexagonsduration
- numeric - positive milliseconds taken by the renderer to draw the hexagonslowEndColor
- string - choose the color for the smaller hexagonshighEndColor
- string - choose the color for the larger hexagons
Note About Coloring - For best readable results, use colors that have high contrast in hue and shade such as red and yellow. White is generally a safe option for the lowEndColor
, but the eye is better at picking up changes in hue than changes in shade. Blue to Yellow is also a good option. Generally highEndColor
and lowEndColor
should be opposites in terms of brightness.
uniformSize
- boolean - choose if the size of the hexagons should be uniform or variable
uniformColor
- string - choose a color to be uniform across the different sizes of hexagons instead of variable colorsizeSummaryFunction
- string - choose a function from 'count', 'sum', 'max', 'min', 'mean', or 'median' or give a valid JS function (in development)sizevar
- string - the name of the variable used to calculate the size of the hex using the sizeSummaryFunction
colorSummaryFunction
- string - choose a function from 'count', 'sum', 'max', 'min', 'mean', or 'median' or give a valid JS function (in development)colorvar
- string - the name of the variable used to calculate the color of the hex using the colorSummaryFunction
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.