title: Confused about passing data frame between functions with RStudio's Shiny
body: <p>I would like two plots to appear. First, a scatter plot and then a line graph. The graphs aren't important. This is my first time using Shiny. What is the best way to have both</p>
  
  <pre><code>  plotOutput("needles"),
    plotOutput("plot")
  </code></pre>
  
  <p>use the data from the same needles data frame? I think I'm getting confused as to how to pass the "needles" data frame between the plotOutput functions. </p>
  
  <pre><code>library(shiny)
  library(tidyverse)
  library(scales)
  
  # Create the data frame ________________________________________________
  create_data &lt;- function(num_drops) {
    needles &lt;- tibble (
      x = runif(num_drops, min = 0, max = 10),
      y = runif(num_drops, min = 0, max = 10)
    )
  }
  
  # Show needles ________________________________________________
  show_needles &lt;- function(needles) {
   ggplot(data = needles, aes(x = x, y = y)) + 
      geom_point()
  
  }
  
  # Show plot __________________________________________________
  show_plot &lt;- function(needles) {
    ggplot(data = needles, aes(x = x, y = y)) + 
      geom_line()
  }
  
  # Create UI
  ui &lt;- fluidPage(
  
    sliderInput(inputId = "num_drops", 
                label = "Number of needle drops:",
                value = 2, min = 2, max = 10, step = 1),
  
    plotOutput("needles"),
    plotOutput("plot")
  
  )
  
  server &lt;- function(input, output) {
  
    output$needles &lt;- renderPlot({
      needles &lt;- create_data(input$num_drops)
      show_needles(needles)
    })
  
    output$plot &lt;- renderPlot({
      show_plot(needles)
    })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>