title: how to delete an input in shiny renderUI?
body: <p>In my shiny app I have a dynamic input using renderUI.</p>
  
  <p>This works very well, and another part of the program captures the input of the sliders.  </p>
  
  <p>When the application changes of status (e.g. when the button "update model" is pressed) I still need to display / use sliders with similar labels but as they are "new" the value needs to be re-initialised to zero.</p>
  
  <p>The problem is that the sliders have a memory. If I re-use the same inputId </p>
  
  <pre><code>  paste0(Labv[i], "_v",buttn)
  </code></pre>
  
  <p>shiny will have the old value associated to it.  </p>
  
  <p>Currently my code is using the variable <code>buttn</code>  to bypass the problem: every time the status changes I create "new" sliders.</p>
  
  <p>On the other hand the more the users will use the app, the more garbage will be collected into shiny.</p>
  
  <p>I tried to use renderUI to send the list of elements to NULL, experimenting with sending a list of</p>
  
  <pre><code>updateTextInput(session, paste0(lbs[i],"_v",buttn),
              label = NULL,  value = NULL )
  </code></pre>
  
  <p>or <code>tags$div("foo", NULL)</code>  but in each case the actual variable was rendered as text, which is worst!</p>
  
  <pre><code># Added simplified example
  library(shiny)
  library(data.table)
  
  #
  dt_ = data.table( Month = month.abb[1:5],
  A=rnorm(5, mean = 5, sd = 4),
  B=rnorm(5, mean = 5, sd = 4),
  C=rnorm(5, mean = 5, sd = 4),
  D=rnorm(5, mean = 5, sd = 4),
  E=rnorm(5, mean = 5, sd = 4))
  
  dt_[,id :=.I]
  dt &lt;- copy(dt_)
  setkey(dt_, "Month") 
  setkey(dt, "Month")
  
  shinyApp(
    ui = fluidPage(
  fluidRow(
    column(4, 
      actionButton("saveButton", "Update Model"))),
  fluidRow(
    column(6, dataTableOutput('DT')),
    column(3, br(),br(),checkboxGroupInput("pick",h6("Picker"), 
      month.abb[1:5])),  
    column(3, uiOutput('foo'))),
  fluidRow(
    column(4, verbatimTextOutput('vals')))    
    ),
  
    server = function(session,input, output) {
      valPpu &lt;- reactiveValues()
  
      valPpu$buttonF &lt;- 1
      valPpu$dt_ &lt;- dt_
  ##
    output$DT &lt;- renderDataTable({
    if(length(input$pick) &gt; 0 ) {
  # browser()
      isolate( { labs &lt;- input$pick } ) # 
      buttn &lt;- valPpu$buttonF
  
      iter &lt;- length(labs)   
      valLabs &lt;- sapply(1:iter, function(i) {
              as.numeric(input[[paste0(labs[i],"_v",buttn)]]) })
  
      if( iter == sum(sapply(valLabs,length)) ) {        
  
            cPerc &lt;- valLabs
            cPerc &lt;- as.data.table(cPerc)
            cPercDt &lt;- cbind(Month=labs,cPerc)
  
            ival &lt;- which(dt[["Month"]] 
                %in% cPercDt[["Month"]])
            setkey(cPercDt, "Month") 
            for(j in LETTERS[1:5]) set(dt_, i=ival, 
            j=j, dt[cPercDt][[j]] * (1 + dt_[cPercDt][["cPerc"]]) )
            valPpu$dt_ &lt;- dt_
    } }
  
    dt_[order(id),]
    }, options = list(
    scrollX = TRUE,
    scrollY = "250px" ,
    scrollCollapse = TRUE,
    paging = FALSE,
    searching = FALSE,
    ordering = FALSE )
  )
  ##
    output$foo &lt;- renderUI({
      if(is.null(input$saveButton)) { return() }
      if(length(input$pick) &gt; 0 ) {
        labs &lt;-  input$pick 
        iter &lt;- length(labs)
        buttn &lt;- isolate(valPpu$buttonF )
        valLabs &lt;- sapply(1:iter, function(i) {
        if(is.null(input[[paste0(labs[i],"_v",buttn)]] )) {
                  0
        } else {  as.numeric(input[[paste0(labs[i],"_v",buttn)]])  }
        }) 
    #
    toRender &lt;- lapply(1:iter, function(i) {
      sliderInput(inputId = paste0(labs[i], "_v",buttn),
                  label =  h6(paste0(labs[i],"")),
                  min = -1,
                  max = 1,
                  step = 0.01,
                  value = valLabs[i],
                  # format = "##0.#%",
                  ticks = FALSE, animate = FALSE)
                  })
  
        toRender
      }
      })
  
  
      observe({
  
    if(is.null(input$saveButton)) { return() }
    if(input$saveButton &lt; valPpu$buttonF) { return() }
    valPpu$buttonF &lt;- valPpu$buttonF + 1
    dt &lt;&lt;- valPpu$dt_
  # TODO: add proper saving code  
  })
    }
  )
  </code></pre>
  
  <p>In the actual app the checkboxGroupInput is also driven from the server with renderUI and is reset when the "update model" is pressed. Also, there are more "events" in the UI that I haven't added to the code.</p>
  
  <p>Any idea?</p>