title: conditional panel combined with reactivity in shiny
body: <p>I am writing a shiny app to realize the following effects:</p>
  
  <p>Whenever I choose variable included by <code>categoryname</code>, the web will generate the slider (here I use conditional panel) which provides a divider. It divides the selected variable into 2 groups and form a new column added to the original data set.</p>
  
  <p>The web page can be generated now. My problem is:</p>
  
  <ol>
  <li><p>The slider should be hided when I am not choosing the variable in <code>categoryname</code>, but it always appears.</p></li>
  <li><p>Whenever I choose the variable in <code>categoryname</code>, the page will exit.</p></li>
  </ol>
  
  <p>The error shows:</p>
  
  <pre><code>Warning in max(MT_EG$id_arm) :
    no non-missing arguments to max; returning -Inf
  Warning in input$divider$max &lt;- max(MT_EG$id_arm) :
    Coercing LHS to a list
  Warning: Error in $&lt;-.reactivevalues: Attempted to assign value to a read-only reactivevalues object
    75: stop
    74: $&lt;-.reactivevalues
    72: observeEventHandler [/opt/bee_tools/shiny/3.5.1/users/denga2/teal.modules.km/testapp/app.R#75]
     1: runApp
  </code></pre>
  
  <p>Well the attempt to change the max an min of the slider isn't the only cause. When I set it to be fixed, the page also exits.</p>
  
  <p>Here in the code I simply use mtcars dataset so that all of you can get access to. </p>
  
  <pre><code>library(shiny)
  
  categoryname = c("mpg_group", "disp_group")
  MT_EG = mtcars[,1:5]
  
  # Define UI for application that draws a histogram
  ui &lt;- fluidPage(
  
     # Application title
     titlePanel("Mtcars Data"),
  
     # Sidebar with a slider input for number of bins 
     sidebarLayout(
        sidebarPanel(
  
           selectInput(inputId = "arm",
                       label = "ARM VARIABLE",
                       choices = c("mpg_group", "cyl", "disp_group", "hp", "drat"),
                       selected = "cyl"),
  
           conditionalPanel(
             condition = "categoryname.includes(input.arm)",
             #condition = "categoryname == input.arm",
  
             #optionalSliderInputValMinMax("divider", "divide slider", c(50,0,100), ticks = FALSE)
             sliderInput("divider", "divide slider", 0, 100, 50)
           )
        ),
  
        # Show a plot of the generated distribution
        mainPanel(
           uiOutput("data")
        )
     )
  )
  
  # Define server logic required to draw a histogram
  server &lt;- function(input, output, session) {
  
     observeEvent(
       input$arm,
       {
       if (input$arm %in% categoryname){
         # start over and remove the former column if exists
         MT_EG = MT_EG[, !(colnames(MT_EG) %in% input$arm)]
  
         id_arm_var &lt;- input$arm
         id_arm &lt;- unlist(str_split(id_arm_var,'_'))[1]
  
         # change the range of the slider
         input$divider$max = max(MT_EG$id_arm)
         input$divider$min = min(MT_EG$id_arm)
  
         # generate a new column and bind
         divi &lt;- data.frame(id_arm_var = MT_EG$id_arm&gt;input$divider)
         divi$id_arm_var[divi$id_arm_var==TRUE] &lt;- paste0(id_arm_var, " Larger")
         divi$id_arm_var[divi$id_arm_var==FALSE] &lt;- paste0(id_arm_var, " Smaller")
         MT_EG &lt;- cbind(MT_EG,divi)
       }
  
     output$data=renderTable(MT_EG)
     })
  }
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Any ideas? Thank you guys!</p>