How to overcome Leaflet's colorQuantile failing with a variable with many zeros

1,356 views
Skip to first unread message

Mihir Iyer

unread,
Aug 4, 2016, 3:36:40 PM8/4/16
to Shiny - Web Framework for R
I'm working on building a leaflet map to show 9 numerical variables. This map is a shiny app where the user selects a variable which is then mapped (polygons). The problem I'm running into is with two of the variables which happen to take on the value of zero very frequently roughly 3000 out of 3200 observations. When either of those variables are selected I an error message like Breaks are not Unique. The same issue occurs when using colorBin.

So I'm reluctantly thinking of building in logic that would use colorNumeric for the two variables that are mostly zero, though it doesn't do much in terms coloring but it does prevent the app from freezing. My other idea is to subset the dataset for the two variables and drop all the zero values. I could us some help in assessing these options and any others. A recap of the options for the two variables:

1. switch to numeric color palette. Pro - app works, Cons - color scheme doesn't do much
2. drop zero value location from the data set. Pro - app works and the colors kind of work. Con - many locations are dropped.
3. any other options?

Joe Cheng

unread,
Aug 4, 2016, 3:52:24 PM8/4/16
to Mihir Iyer, Shiny - Web Framework for R
If you have such a heavily skewed distribution it seems like quantile is inherently a bad choice, right? How about using colorBin instead?
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/d5bb1492-5a24-4227-9959-4605fd355ecc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages