I have a shiny application where the filters here are reactive with respect to each other. Not sure there is some issue in the code. The values are not to be seen here. Can anyone help me here?
Is there any alternate way?
library(shiny)
library(readxl)
library(dplyr)
library(shinyWidgets) ## for picker input
library(shinydashboard)
library(DT)
library(tidyverse)
library(xtable)
library(shinycssloaders)
library(plotly)
library(htmlwidgets)
library(sparkline)
library(data.table)
require(reshape2)
library(glue)
data_13_Sam <- data.frame(
Ratings = c(1,2,3,4,5,1,2,3,4,5), flag = c("Yes","No","Yes","No","Yes","No","Yes","No","Yes","Yes")
)
ui <- fluidPage(
column(offset = 0, width = 1,uiOutput("rat")),
column(offset = 0, width = 2, uiOutput("nt"))
)
server <- function(input, output, session) {
filter_data <- reactive({
data_13_Sam %>% filter(flag %in% input$nt, Ratings %in% input$rat)
})
##### nt
output$nt <- renderUI({
selectInput("nt",label = tags$h4("New"),choices = unique(filter_data()$flag))
})
###### rat
output$rat <- renderUI({
selectInput("rat",label = tags$h4("Rat"),choices = unique(filter_data()$Ratings))
})
}
shinyApp(ui, server)
Can we not make it reactive to each other. In my question, 5 does not have "No", So when we select "No" under "New", the other filter should not have 5. Also when we select 5 under "Rat", the other filter should not have "No". Make sense ?