title: R shiny build links between tabs
body: <p><strong>[Code]</strong></p>
  
  <pre><code>library(shiny)
  
  server &lt;- function(input, output) {
    output$iris_type &lt;- renderDataTable({
      data.frame(Species=paste0("&lt;a href='#filtered_data'&gt;", unique(iris$Species), "&lt;/a&gt;"))
    })
    output$filtered_data &lt;- renderDataTable({iris})
  }
  
  ui &lt;- shinyUI(fluidPage(
    mainPanel(
      tabsetPanel(
        tabPanel("Iris Type", dataTableOutput("iris_type")),
        tabPanel("Filtered Data", dataTableOutput("filtered_data"))
      )
    )
  ))
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p><strong>[Question]</strong></p>
  
  <p>I am trying to link the <code>DataTable</code> output on first tab to the second tab. For example, when I click on <code>setosa</code>, the next thing showing up is second tab with <code>iris</code> dataset containing only <code>setosa</code>. It should execute this piece of code from R: <code>iris[iris$Species=="setosa",]</code>. It should work for other <code>Species</code> in <code>iris</code> too.</p>
  
  <p>How can I build up the link and run that R command by clicking?</p>
  
  <hr>
  
  <p><strong>[Update on answer]</strong></p>
  
  <p>In case you have a different layout and needs to be specific, here is what you can do.</p>
  
  <ol>
  <li><p>Your <code>DataTable</code> callback function:</p>
  
  <pre><code>callback =
  "function(table) {
     table.on('click.dt', 'tr', function() {
       Shiny.onInputChange('rows', table.row(this).data()[0] );
       $(\".tabbable .nav.nav-tabs li a:contains('Filtered Data')\").click();
     });
   }"
  </code></pre></li>
  <li><p>Your <code>R</code> code:</p>
  
  <pre><code>output$filtered_data &lt;- renderDataTable({
    tagString &lt;- input$rows
    rawTags &lt;- gsub("&lt;/a&gt;", "", gsub("&lt;a href='#filtered_data'&gt;", "", tagString))
  
    if (identical(tagString, character(0))) {
      iris
    } else {
      ...
    }
  })
  </code></pre></li>
  </ol>