title: Make object created inside one reactive object available to another in shiny
body: <p>I have a shiny app in which I define an object based on sliders and create a <code>data.frame</code> from it. This gets used to create a plot, below which I'd like to include a summary table. My issue is that the plot must be defined inside of a reactive object to update based on the sliders, but I found that when I tried to access the object to print a summary inside of a <em>different</em> reactive object, it wasn't found.</p>
  
  <p>I'd like to not run through the same calculation code twice just to get the object into the other reactive object. My two initial ideas:</p>
  
  <ul>
  <li>I tried using <code>save(object, file = "...")</code> inside the first reactive object and then putting <code>load(file = "...")</code> inside the second, but it doesn't update.</li>
  <li>I thought of defining my object outside of my reactive <code>plotOutput</code> definition, but I'm pretty sure it won't update when user inputs are changed; it will just stay with the value of the initial <code>input</code> object default settings.</li>
  </ul>
  
  <p>Well, just went ahead and tried the latter idea, and it doesn't even get that far:</p>
  
  <ul>
  <li>I put it before <code>shinyServer(...)</code> and it can't generate the data because my call depends on <code>input</code> and it doesn't know about <code>input</code> at that point.</li>
  <li>I put it after <code>shinyServer(...)</code> but before <code>renderPlot(...)</code> to try and make sort of a "globally available" object for all output objects, and it scolding me for trying to do something that uses <code>input</code> outside of a reactive function.</li>
  </ul>
  
  <p>Here's an example to illustrate, modified from Shiny's <a href="http://rstudio.github.io/shiny/tutorial/#hello-shiny" rel="noreferrer">"Hello Shiny!" example</a>:</p>
  
  <p><strong>ui.R</strong></p>
  
  <pre><code>library(shiny)
  
  # Define UI for application that plots random distributions 
  shinyUI(pageWithSidebar(
  
    # Application title
    headerPanel("Hello Shiny!"),
  
    # Sidebar with a slider input for number of observations
    sidebarPanel(
      sliderInput("obs", 
                  "Number of observations:", 
                  min = 1,
                  max = 1000, 
                  value = 500)
    ),
  
    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("distPlot"),
      tableOutput("summary")
    )
  ))
  </code></pre>
  
  <p><strong>server.R</strong></p>
  
  <pre><code>library(shiny)
  
  # Define server logic required to generate and plot a random distribution
  shinyServer(function(input, output) {
  
    output$distPlot &lt;- renderPlot({
  
      # generate an rnorm distribution and plot it
      dist &lt;- rnorm(input$obs)
      hist(dist)
    })
  
    output$summary &lt;- renderTable({
      #dist &lt;- rnorm(input$obs)
      summary &lt;- table(data.frame(cut(dist, 10)))
    })
  })
  </code></pre>
  
  <p>If you run it as is, <code>cut</code> will throw and error because it doesn't know about <code>dist</code>. If you uncomment the line where we re-define <code>dist</code> as is done in <code>plotOutput</code>, then it will work.</p>
  
  <p>This is simple code -- mine is quite a bit more involved and I'd really prefer not to run it twice just to make the same result known to another reactive output.</p>
  
  <p>Suggestions?</p>