title: Display Tables on Tabs
body: <p>I have two tables containing different sets of data.  I want the tables to be displayed on separate tabs. My code works perfectly when I display just one table, but whenever I try to display both the tables values are no longer displayed, just the various titles.  Any help is much appreciated.  Below is my code.  I use the Lahman database and DT package.  </p>
  
  <p>server.R:</p>
  
  <pre><code>library(shiny)
  library(ggplot2)
  
  
  # Define a server for the Shiny app
  shinyServer(function(input, output) {
  
   # Filter data based on selections
  output$table &lt;- DT::renderDataTable(DT::datatable({
  data &lt;- Pitching
  if (input$yearID != "All") {
    data &lt;- data[data$yearID == input$yearID,]
  }
  if (input$lgID != "All") {
    data &lt;- data[data$lgID == input$lgID,]
  }
  if (input$teamID != "All") {
    data &lt;- data[data$teamID == input$teamID,]
  }
  data
  }))
  
  output$table2 &lt;- DT::renderDataTable(DT::datatable({
  data &lt;- Batting
  if (input$yearID != "All") {
    data &lt;- data[data$yearID == input$yearID,]
  }
  if (input$lgID != "All") {
    data &lt;- data[data$lgID == input$lgID,]
  }
  if (input$teamID != "All") {
    data &lt;- data[data$teamID == input$teamID,]
  }
  data
  }))
  
  
  })
  </code></pre>
  
  <p>ui.R:</p>
  
  <pre><code>library(shiny)
  
  # Load the ggplot2 package which provides
  # the 'mpg' dataset.
  library(ggplot2)
  
  # Define the overall UI
  shinyUI(
    fluidPage(
     titlePanel("Pitching"),
  
     # Create a new Row in the UI for selectInputs
     fluidRow(
      column(4,
           selectInput("yearID",
                       "Year:",
                       c("All",
                         unique(as.integer(Pitching$yearID))))
    ),
    column(4,
           selectInput("lgID",
                       "League:",
                       c("All",
                         unique(as.character(Pitching$lgID))))
    ),
    column(4,
           selectInput("teamID",
                       "Team:",
                       c("All",
                         unique(as.character(Pitching$teamID)))))
  ),
  
  # Create a new row for the table.
  fluidRow(
    DT::dataTableOutput("table")
  
  ),
  
  fluidPage(
    titlePanel("Batting"),
  
    # Create a new Row in the UI for selectInputs
    fluidRow(
      column(4,
             selectInput("yearID",
                         "Year:",
                         c("All",
                           unique(as.integer(Batting$yearID))))
      ),
      column(4,
             selectInput("lgID",
                         "League:",
                         c("All",
                           unique(as.character(Batting$lgID))))
      ),
      column(4,
             selectInput("teamID",
                         "Team:",
                         c("All",
                           unique(as.character(Batting$teamID)))))
    ),
  
    # Create a new row for the table.
    fluidRow(
      DT::dataTableOutput("table2")
  
    ),
  
    mainPanel(
      tabsetPanel(type = "tabs",
      tabPanel("Pitching",tableOutput("table")),
      tabPanel("Batting", tableOutput("table2"))
    )
  )
   )
    ))
  </code></pre>