title: R shiny: download multiple .csv files
body: <p>I have an issue regarding Shiny on R. I have a function which returns a list with 2 objects as output, both as a matrix. The first one is always created and is always available for download. The second one, is combined with a condition displayed as a checkbox.</p>
  
  <p>global</p>
  
  <pre><code>physical_check &lt;- function(file_path, x,y,z, classification)
  input: String, int, int, int, boolean
  output: list(matrix1 = result, matrix2 = rating)
  </code></pre>
  
  <p>UI:</p>
  
  <pre><code>ui &lt;- fluidPage(   
     # Application title
     titlePanel("Review"),
  
     # Sidebar with a slider input for number of bins 
     sidebarLayout(
       sidebarPanel(
         fileInput('file1', 'Choose .txt File',
                   accept=c('text/csv','text/comma-separated,text/plain')),
         hr(),
  
         checkboxInput("classification", "Use Text-Classification", value = FALSE),
         hr(),
  
         downloadButton("download_physic", "Physical Review"),
         br(),
         conditionalPanel(condition = "input.classification == true", 
                          downloadButton("download_classify", "Text Classification"))
  
       ),
       mainPanel(
         h3("Review"),
         tableOutput("rating"),
         tableOutput("result_shiny")
       )
     )
  
  )
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>server &lt;- function(input, output) {
    inFile &lt;- reactive({
      input$file1
    })
    result &lt;- reactive({NULL})
  
      classify &lt;-  reactive({
      input$classification
    })
  
    observe({
      if (!is.null(inFile())) {
        result &lt;- reactive({
          withProgress({
            setProgress(message = "Processing review...")
            physical_check(as.String(inFile()$datapath),15,8,3,classify())
          })
        })
      }  
  
    output$result_shiny &lt;- renderTable({
      result()$result
    })
      output$rating &lt;- renderTable({
      result()$rating
    })
  
    output$download_physic &lt;- downloadHandler(
      filename = function() {
        sub(pattern = "\\.txt",replacement = "_result.csv",inFile()$name)
      },
      content = function(file) {
        write.table(
          result()$result,
          file,
          sep = ";",
          col.names = NA,
          qmethod = "double"
        )
      }
    )
  
    output$download_classify &lt;- downloadHandler(
      filename = function() {
        paste("rating", ".csv")
      },
      content = function(file) {
        write.table(
          result()$rating,
          file,
          sep = ";",
          col.names = NA,
          qmethod = double
        )
      }
    )
    }) 
  }
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>So as you can see in the code I mentioned a conditional download button for the text classification, if the checkbox is triggered.
  According to this TRUE/FALSE value the function <code>physical_check</code>is called with true or false and returns a matrix and NULL or 2 matrizes and only in the second option, the download button is displayed.
  I'm a little bit confused, because with <code>tableOutput</code>I receive the correct tables in the main panel, also downloading the <code>physical review</code>with the first downloading part works fine.
  But the second one fails in google chrome with a download error:</p>
  
  <pre><code>download_classify
  Failed - Server problem
  </code></pre>
  
  <p>Although it's constructed the same way.</p>