title: Refreshing UI of Shiny app
body: <p>I am creating a Shiny app which has a drop down list which needs to be updated based on the radio button clicked. I do update the list based on the radio button, but the last choice from the previous option still remains. I am including the code to make this more clear</p>
  
  <pre><code>  ui.R
    fluidRow(
                              column(3,
                                     radioButtons("matchType", label = h3("Match type"),
                                                  choices = list("Test" = "Test",
                                                                 "ODI" = "ODI", 
                                                                 "Twenty20" = "TT"), 
                                                  inline=TRUE,
                                                  selected = "Test"),
                                     selectizeInput(
                                         "batsman", label = "Players", choices = NULL, multiple=FALSE,selected="tendulkar",
                                         options = list(create = TRUE,placeholder = 'Choose the player',size=12)
  
                                     ),
                                     selectizeInput(
                                         "batsmanFunc", label = "Choose chart type", choices = NULL, multiple=FALSE,selected="4s of batsman",
                                         options = list(create = TRUE,placeholder = 'Choose the chart')
  
                                     )
  
                              ),
  </code></pre>
  
  <p>I have set up server.R as follows</p>
  
  <pre><code> server.R
  
   output$batsmanPlot &lt;- renderPlot({  
      # Include the list to display in the drop downs on choice of matchType
      if(input$matchType == "Test"){
  
          updateSelectizeInput(session, 'batsman', choices = testBatsman, server = TRUE,selected=input$batsman)
          updateSelectizeInput(session, 'batsmanFunc', choices = funcs, server = TRUE,selected=input$batsmanFunc)
  
      } else {
  
          updateSelectizeInput(session, 'batsman', choices = odiBatsman, server = TRUE,selected=input$batsman)
          updateSelectizeInput(session, 'batsmanFunc', choices = funcsODITT, server = TRUE,selected=input$batsmanFunc)
      }
      print(input$batsman)
      analyzeBatsman(input$batsman,input$batsmanFunc,input$matchType)
  
  })
  </code></pre>
  
  <p>There are 2 issues
  1) Since I use selected=input$batsman, the drop down is blank initially. If I chose a fixed value for this, then every time  choose another value it displays the new value and then returns back to the selected value. I think this is because updateSelectize is inside renderPlot</p>
  
  <p>2) When I switch between radio buttons "Test"/"ODI", the last selected player is not cleared out. The new list is appended to the last selected player. The next time around, it is the actual list.</p>
  
  <p>How can this be addressed?</p>