Using "addHexbin" in leaflet.extras2 only counts the number of records in each hexbin but there are many use cases for the mean, sum or other calculations within the hexbin. For example a dataset that is a list of species and the abundance of each species. Instead of a count of the number of times a species appears in each hexbin it would be useful to have the total or average abundance in a hexbin. In the example below there is no way to account for or access the abun column when using addHexbin.
library(leaflet)
library(leaflet.extras2)
n <- 100000
df <- data.frame(lat = rnorm(n, 42.0285, .01),
lng = rnorm(n, -93.65, .01),
abun = rnorm(n, 20000, 1000))
leaflet(df) %>%
addTiles() %>%
addHexbin(lng = ~lng, lat = ~lat,
options = hexbinOptions(
colorRange = c( "purple","blue","green", "yellow"),
radiusRange = c(1, 20)
))
Using "addHexbin" in leaflet.extras2 only counts the number of records in each hexbin but there are many use cases for the mean, sum or other calculations within the hexbin. For example a dataset that is a list of species and the abundance of each species. Instead of a count of the number of times a species appears in each hexbin it would be useful to have the total or average abundance in a hexbin. In the example below there is no way to account for or access the abun column when using addHexbin.