title: Shiny reactive dataset within observeEvent
body: <p>I have a very simple app which fails. The reason it fails is that the reactive dataset is available solely within the observeEvent function but not outside. I use observeEvent to get datasets from two different sources wrangled. For this example I simply used cbind. My actual code is much more complicated. </p>
  
  <p>This is a logical / syntax related problem but all my searching came up short. In essence I want merged_data() to be available for all parts of the app.</p>
  
  <p>Minimum repr example - this <strong>fails</strong> because merged_data() is not available outside of the ObserveEvent.</p>
  
  <pre><code>library(shiny)
  library(shinyjs)
  library(DT)
  
  # Define UI for application that draws a histogram
  ui &lt;- fluidPage(
  
     # Application title
     titlePanel("testing 1 2 3"),
  
     # Sidebar with a slider input for number of bins 
     sidebarLayout(
        sidebarPanel(
        ),
  
  
        # Show a plot of the generated distribution
        mainPanel(
           fluidRow(
              column(width = 2,
                     offset = 0,
                     align = "center",
                     actionButton(inputId = "fetch_data_inputId",
                                  label = "data")
  
              ) #column
              ,
              column(width = 10,
                     offset = 0,
                     align = "center",
                     DT::dataTableOutput("DT1")
              ) #column
  
           )#fluidrow
        )
     )
  )
  
  # Define server logic required to draw a histogram
  server &lt;- function(input, output,session) {
  
     observeEvent(input$fetch_data_inputId, {
  
        req(iris) 
  
        button_data &lt;- colnames(iris)
  
        merged_data &lt;- reactive({
  
           if( !is.null(cbind(iris[,1:4],iris3))) {
              cbind(iris[,1:4],iris3)
           } else {NULL}
        })
  
  
     }) #observeevent
  
     output$DT1 &lt;- renderDataTable({#
  
        rendered_table &lt;- merged_data()
  
        DT::datatable(rendered_table)
     })   
  
  
  }
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Minimum repr example - this <strong>works</strong> because the datatable is created within the ObserveEvent. </p>
  
  <pre><code>library(shiny)
  library(shinyjs)
  library(DT)
  
  # Define UI for application that draws a histogram
  ui &lt;- fluidPage(
  
     # Application title
     titlePanel("testing 1 2 3"),
  
     # Sidebar with a slider input for number of bins 
     sidebarLayout(
        sidebarPanel(
        ),
  
  
        # Show a plot of the generated distribution
        mainPanel(
           fluidRow(
              column(width = 2,
                     offset = 0,
                     align = "center",
                     actionButton(inputId = "fetch_data_inputId",
                                  label = "data")
  
              ) #column
              ,
              column(width = 10,
                     offset = 0,
                     align = "center",
                     DT::dataTableOutput("DT1")
              ) #column
  
           )#fluidrow
        )
     )
  )
  
  # Define server logic required to draw a histogram
  server &lt;- function(input, output,session) {
  
     observeEvent(input$fetch_data_inputId, {
  
        req(iris) 
  
        button_data &lt;- colnames(iris)
  
        merged_data &lt;- reactive({
  
           if( !is.null(cbind(iris[,1:4],iris3))) {
              cbind(iris[,1:4],iris3)
           } else {NULL}
        })
  
  
        output$DT1 &lt;- renderDataTable({#
  
           rendered_table &lt;- merged_data()
  
           DT::datatable(rendered_table)
        })   
  
     }) #observeevent
  
  
  
  }
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>What I really need is for the reactive dataset to continue being created within observeEvent but to be accessible outside of the ObserveEvent environment so that i use it in other parts of the app, but I suspect it's the wrong approach. So anything that works would be great.</p>