Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"addHexbin" in leaflet.extras2 doesn't allow for mean/sum #49

Open
vkentner opened this issue Oct 31, 2022 · 3 comments
Open

"addHexbin" in leaflet.extras2 doesn't allow for mean/sum #49

vkentner opened this issue Oct 31, 2022 · 3 comments
Labels
upstream Bug in upstream repo

Comments

@vkentner
Copy link

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)
              )) 
@trafficonese
Copy link
Owner

I will look into it. Sounds very reasonable!

@trafficonese trafficonese added the upstream Bug in upstream repo label Feb 21, 2023
@trafficonese
Copy link
Owner

This would have to be handled in the upstream plugin library.
Unfortunately, there's not much i can do on the R-side.

@trafficonese
Copy link
Owner

I am working on clusterCharts #69 that make it possible to cluster and aggregate values from point markers using d3 functions, like sum/min/max/mean/median.

I thought that could be interesting for you @vkentner.

After installing the PR you can check out this Shiny-App:

runApp(system.file("examples/clustercharts_sum.R", package = "leaflet.extras2"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Bug in upstream repo
Projects
None yet
Development

No branches or pull requests

2 participants