addHexbin: Hexbin Layers for Leaflet Plots

Description Usage Arguments Value Note See Also Examples

View source: R/hexbin.R

Description

Create hexbin layers for leaflet plots.

Usage

1
2
3
4
5
6
addHexbin(map, data = NULL, radius = 12, opacity = 0.5,
  duration = 500, lowEndColor = "white", highEndColor = "blue",
  uniformSize = FALSE, uniformColor = NULL,
  sizeSummaryFunction = c("count", "sum", "max", "min", "mean",
  "median"), sizevar = NULL, colorSummaryFunction = c("count", "sum",
  "max", "min", "mean", "median"), colorvar = NULL)

Arguments

map

The leaflet map object to apply the hexbin layer to. Makes this function compatible with the %>% operator

data

data frame or tibble - alternate data to use for this hexbin instead of default map data

radius

choose the base size for the hexagons

opacity

decimal between 0.0 and 1.0 - choose the percent of opacity for the hexagons

duration

positive integer milliseconds that the animation takes for drawing the hexagons

lowEndColor

choose the color for the smaller hexagons

highEndColor

choose the color for the larger hexagons

uniformSize

a logical indicating whether all hexagons should be the same size.

uniformColor

a color that overrides lowEndColor and highEndColor to make the color uniform across the hexagon sizes.

sizeSummaryFunction

a string that specifies which summary function to use on sizevar to modulate the size of the hexagons. The options are 'count', 'sum', 'max', 'min', 'mean', and 'median'.

sizevar

a string that specifies which variable in the user specified data frame will be used to calculate the size of the hexagons.

colorSummaryFunction

a string that specifies which summary function to use on colorvar to modulate the color of the hexagons. The options are 'count', 'sum', 'max', 'min', 'mean', and 'median'.

colorvar

a string that specifies which variable in the user specified data frame will be used to calculate the color of the hexagons.

Value

map parameter, but with the hexbinLayer attached so that it can be used with the %>% pipe operator

Note

Do not use uniformColor and uniformSize together as it will not give any insights to the data

If colorSummaryFunction and colorvar are not specified, the color will mirror the sizevar unless uniform color set to TRUE.

See Also

A JSFiddler Hexbin example by Ryan

Examples

1
2
3
4
5
leaflet::leaflet(data.frame(lat =  42.9634 + rnorm(1000),lng = -85.6681 + rnorm(1000))) %>%
addTiles() %>% addHexbin()

leaflet::leaflet(data.frame(lat =  42.9634 + rnorm(1000),lng = -85.6681 + rnorm(1000))) %>%
addTiles() %>% addHexbin(radius=25, lowEndColor='purple', highEndColor='orange')

leaflethex documentation built on Sept. 4, 2019, 9:03 a.m.