title: Rshiny: Make reactive plot with data from reactive function
body: <p>I'm making a shiny app in an Rmarkdown file using flexdashboard and I'm having trouble making a ggplot with data from a reactive function.</p>
  
  <p>These are the steps/elements:</p>
  
  <ol>
  <li>Get input from radiobuttons asking for a date, and print the answer
  (to check if he reacts fine) -> works</li>
  <li>Reactive function reading the relevant csv-file (based on the date)
  and printing it's contents (to check) -> works</li>
  <li>ggplot made with the contents of the csv-file -> does not work</li>
  </ol>
  
  <p>When I use renderPlot() to make a ggplot with a non-reactive dataset (I loaded one), I get the correct result, so the ggplot-part is fine.</p>
  
  <p>It has something to do with the reactive en renderPlot combinations, but I can't seem to figure it out. Although it's an "easy" concept, I keep having problems grasping the workflow, despite watching several movies and reading several guides.</p>
  
  <p>This is my current code:</p>
  
  <pre><code>---
  title: "Tests plot" 
  output: 
    flexdashboard::flex_dashboard:
      orientation: columns
      vertical_layout: fill
  runtime: shiny
  ---
  
  ```{r setup, include=FALSE}
  library(flexdashboard)
  library(shiny)
  library(ggplot2)
  ```
  
  Input {.sidebar}
  ======================================
  ```{r}
  radioButtons("countdate",h3("Datum"), c("01-12-2017"="T1","06-12-2017"="T2","24-12-2017"="T3"))
  ```
  
  Data
  ======================================
  Column
  -----------------------------------------------------------------------
  ### Date
  ```{r}
  reactive({ #OK
    input$countdate
  })
  ```
  
  Column
  -----------------------------------------------------------------------
  ### Data
  ```{r}
  fake2 &lt;- reactive({read.csv2(paste(input$countdate, ".csv", sep = ""))})
  fake2 #OK
  ```
  
  Column
  -----------------------------------------------------------------------
  ### Plot
  ```{r}
  ggplot1 &lt;- reactive({
    renderPlot({ggplot(fake2, aes(Rij, Plant)) +
        xlim(0,40) +
        ylim(0,50) +
        coord_equal() +
        geom_raster(aes(fill=Wtot)) +
        scale_fill_gradient(low="yellow", high="red")
      })
  })
  
  ggplot1
  ```
  </code></pre>
  
  <p>I also tried this in the plot-part:</p>
  
  <pre><code>renderPlot({
   ggplot(fake2, aes(Rij, Plant)) +
    xlim(0,40) +
    ylim(0,50) +
    coord_equal() +
    geom_raster(aes(fill=Wtot)) +
    scale_fill_gradient(low="yellow", high="red")
  })
  </code></pre>
  
  <p>My data look like this:</p>
  
  <pre><code>Vplaat;Rij;Plant;Mtot;Wtot
  A;4;10;2;20
  B;4;46;5;35
  C;9;5;1;14
  D;9;30;0;42
  E;11;17;8;85
  ...
  </code></pre>