Hi, it is possible create use a grey when the value in nycounties$dimension is 0 and in the rest use the palette? How can I do it?
library(leaflet)
nycounties <- rgdal::readOGR("https://raw.githubusercontent.com/openpolis/geojson-italy/master/geojson/limits_IT_provinces.geojson")
city <- c("Novara", "Milano","Torino","Bari")
dimension <- as.numeric(c("1500", "5000","3000","4600"))
df <- data.frame(city, dimension)
nycounties@data = data.frame(nycounties@data,
df[match(nycounties@data[, "prov_name"],
df[, "city"]),])
pal <- colorNumeric("viridis", NULL)
nycounties$dimension[is.na(nycounties$dimension)] = 0
leaflet(nycounties) %>%
addTiles() %>%
addPolygons(stroke = TRUE, smoothFactor = 0.3, fillOpacity = 1,
fillColor = ~pal(nycounties$dimension), weight = 1, color = "black", label = nycounties$prov_name) %>%
addLegend(pal = pal, values = ~(nycounties$dimension), opacity = 1.0)