title: R shiny: renderTable reset input$tableid_rows_selected value
body: <p><strong>Background :</strong> I'm creating a simple table using the following code:  </p>
  
  <pre><code>output$mytable = DT::renderDataTable({
                datatable(data_frame_object, selection='single')
                }) 
  </code></pre>
  
  <p>Note that <code>selection='single'</code> makes it so that only one row is shown as selected at a time. 
  I track the row that is selected by the user by using the following code: </p>
  
  <pre><code>index=input$mytable_rows_selected
  </code></pre>
  
  <p><strong>Problem :</strong>  The problem I am having is that I want to reset the value of <code>index=input$mytable_rows_selected</code> every time a new row is selected. 
  Currently, if user selects row 1, the index will have value [1]. If user then selects row 2, then index will have value of [1, 2]. However, I just want index to have value of [2].</p>
  
  <p><strong>Attempted solution:</strong>  My workaround has been to use index[length(index)] to get the row that was last selected,but this is not suitable for my purposes. </p>
  
  <p><strong>Working example using iris data:</strong></p>
  
  <pre><code>library(shiny)
  library(DT)
  
  server &lt;- function(input, output, session) {
  
    output$mytable = DT::renderDataTable({
      datatable(iris[,c(1,4,5)],selection='single')
    }, 
    options = list(lengthMenu = c(5, 30, 50), pageLength = 10, orderClasses=TRUE)
    ) 
  
    output$info = DT::renderDataTable({
  
      index=input$mytable_rows_selected
  
      if (length(index)){
        index2=index[length(index)]
      }
      else{
        index2=index
      }
      iris[index2,c(1,4)]
    }, 
    options = list(pageLength = 5, orderClasses=TRUE, searching=FALSE)
    )
  
  }
  
  ui &lt;- fluidPage(
  
    fluidRow(
      column(4,dataTableOutput('mytable')),
  
      column(6,offset=1,
             tabsetPanel(type="tabs", 
                         tabPanel("hi",dataTableOutput('info')))
      )   
    )
  )
  </code></pre>