show(), hide() usage from shinyjs, Shiny
<p>I have a simplified version of a shiny application I developed. What I want is to be able to show dataframe1 when Frame1 actionbutton is pressed and hide dataframe2 and again show dataframe2 when Frame2 actionbutton is pressed and hide dataframe1. I need to print the tables at the same location obviously. Thanks for any help and for your time.</p>

<p>server.R </p>

<pre><code>shinyServer(function(input, output, session) {

  data_for_use &lt;- reactiveValues(d=NULL)

  observeEvent(input$actForFrame1,{
  data_for_use$dataFrame1 &lt;- data.frame(firstColumn= c(1,3,5),secondColumn=c(2,4,6))})

  observeEvent(input$actForFrame2,{
  data_for_use$dataFrame2 &lt;- data.frame(firstColumn= c(10,30,50),secondColumn=c(20,40,60))})

  output$dataFrame1 &lt;- DT::renderDataTable({
    DT::datatable(data_for_use$dataFrame1)
  })

  output$dataFrame2 &lt;- DT::renderDataTable({
    DT::datatable(data_for_use$dataFrame2)
  })

  observeEvent(input$actForFrame1,{
    show("dataFrame1")
    hide("dataFrame2")

  })

  observeEvent(input$actForFrame2,{
    show("dataFrame2")
    hide("dataFrame1")

  }) 
})
</code></pre>

<p>ui.R</p>

<pre><code>library(shinyjs)
library(shiny)
library(DT)

shinyUI(pageWithSidebar(

  headerPanel("Test"),

  sidebarPanel(

    actionButton("actForFrame1", "Frame1"),
    actionButton("actForFrame2", "Frame2")
  ),

  mainPanel(
    useShinyjs(),
    wellPanel("Test",
              conditionalPanel(condition = "input.actForFrame1",
              DT::dataTableOutput("dataFrame1")
              ),
              conditionalPanel(condition= "input.actForFrame2",
              DT::dataTableOutput("dataFrame2"))
              )
  )
)
)
</code></pre>