title: switch in downloadHandler doesn't work R shiny
body: <p>When I download the report it's always the PDF one. I've tested separately each one and they work so the problem comes from the switch but the problem is that I've tried some things and nothing works I don't understand why.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>library(rmarkdown)
  
  ui &lt;- fluidPage(
    selectInput("algo", "Selection de l'agorithme utilise pour la simulation:", choice = list("algo1", "algo2")),
    radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'), inline = TRUE),
    downloadButton("report", "Generate report")
  )
  
  
  
  server &lt;- function(input, output, session) {
    output$report &lt;- downloadHandler(
      filename = switch(input$format,
                        "Word" = function() {
                          paste("reportHtml-", Sys.Date(), ".docx", sep="")
                        }, 
                        "PDF" = function() {
                          paste("reportPDF-", Sys.Date(), ".pdf", sep="")
                        },
                        "Word" = function() {
                          paste("reportHtml-", Sys.Date(), ".html", sep="")
                        }
      ),
  
      content =  switch(input$format,
                        "Word" = function(file1) {
  
                          report &lt;- file.path("C:/R_sources/test/reportWord.Rmd")
                          params &lt;- list(n = input$algo)
                          rmarkdown::render(report, output_file = file1,
                                            params = params,
                                            envir = new.env(parent = globalenv())
                          )
                        },
  
                        "PDF" = function(file2) {
  
                          report &lt;- file.path("C:/R_sources/test/reportPdf.Rmd")
                          params &lt;- list(n = input$algo)
                          rmarkdown::render(report, output_file = file2,
                                            params = params,
                                            envir = new.env(parent = globalenv())
                          )
                        },
  
                        "Word" = function(file3) {
  
                          report &lt;- file.path("C:/R_sources/test/reportWord.Rmd")
                          params &lt;- list(n = input$algo)
                          rmarkdown::render(report, output_file = file3,
                                            params = params,
                                            envir = new.env(parent = globalenv())
                          )
                        }
      )
    )
  }
  
  shinyApp(ui, server)
  </code></pre>