我已经使用颜色分位数方法在r中为我的choropleth传单图上色,以生成闪亮的应用程序。在大多数情况下,它工作正常,除非从三个下拉列表中选择三个指标的组合时只有一个值。任何解决此问题的帮助将不胜感激。非常感谢。
server.r
shape_st <- left_join(shape_st, subsetData(), by = c("censuscode", "st_code"))
req(shape_st$value)
quantileNum <- 4
probs <- seq(0, 1, length.out = quantileNum + 1)
bins <- quantile(shape_st$value, probs, na.rm = TRUE, names = FALSE)
while (length(unique(bins)) != length(bins)) {
quantileNum <- quantileNum - 1
probs <- seq(0, 1, length.out = quantileNum + 1)
bins <- quantile(shape_st$value, probs, na.rm = TRUE, names = FALSE)
}
qpal <- colorBin(carto_pal(7,"Sunset") , shape_st$value, bins = bins, na.color = "#e0e0e0")