The sliders work well, but I want to add a color scale from 1 to 5. All three sliders are on the same scale. Obviously I can do for one, but I would like to do one legend for all three sliders. Thank you very much, any contribution would be appreciated.
library(shiny)
library(leaflet)
library(RColorBrewer)
library(dplyr)
sora= readxl::read_excel('D:/0_ATI_HIDRICA_POOPO/11_NUEVO_ANALISIS/1_DATOS/2_CONSOLIDADO_SIMOVH_2016_2019_F.xls','1_SORA_SHINY')
ui <- bootstrapPage(
tags$style(type = "text/css", "html,body {width:100%;height:100%}"),
leafletOutput("uniSmap", width = "100%", height = "100%"),
absolutePanel(top = 50,right = 50,sliderInput("satisfaction","PH",min(sora$PHValor), max(sora$PHValor),value = range(sora$PHValor), step = 1)),
absolutePanel(top = 200,right = 50,sliderInput("ranking","Aluminio",min(sora$CEValor), max(sora$CEValor),value = range(sora$CEValor), step = 1)),
absolutePanel(top = 350,right = 50,sliderInput("cadmio","Turbiedad",min(sora$TURBValor), max(sora$TURBValor),value = range(sora$TURBValor), step = 1)),
absolutePanel(bottom = 10,left = 10,"Satisfaction Map 2016" ))
server <- function(input, output, session) {
#filteredData <- reactive({sora[sora$PH >= input$range[1] & sora$PH <= input$range[2],]})
#filteredData <- reactive({sora[sora$PH>= input$satisfaction[1] & sora$PH <= input$satisfaction[2]
&sora$AL >= input$ranking[1]& sora$AL <= input$ranking[2],]})
filteredData <- reactive({sora %>%
filter(sora$PHValor >= input$satisfaction[1] &
sora$PHValor <= input$satisfaction[2] &
sora$CEValor >= input$ranking[1] &
sora$CEValor <= input$ranking[2]&
sora$TURBValor >= input$cadmio[1]&
sora$TURBValor <= input$cadmio[2])})
output$uniSmap <- renderLeaflet({
leaflet(sora) %>%
addTiles() %>%
fitBounds(~min(Long), ~min(Lat),
~max(Long), ~max(Lat))
})
observe({
pal <- colorNumeric(palette = "YlOrRd",domain = filteredData@data$sora)
leafletProxy("uniSmap", data = filteredData()) %>%
clearShapes() %>%
clearPopups() %>%
clearMarkers() %>%
addCircles(color = ~pal,radius =500,fillOpacity = 1)
#addMarkers(lat = ~Lat, lng = ~Long, label =~Codigo )
})
}
shinyApp(ui = ui, server = server)