title: R Shiny - Generating report
body: <p>I want to export the html/pdf file from shiny app and I found this
  <a href="https://shiny.rstudio.com/articles/generating-reports.html" rel="nofollow noreferrer">https://shiny.rstudio.com/articles/generating-reports.html</a>.</p>
  
  <p>Then I tried to use the code from this website which is shown blow:</p>
  
  <pre><code>library(shiny)
  
  server &lt;- function(input, output) {
        output$report &lt;- downloadHandler(
    # For PDF output, change this to "report.pdf"
        filename = "report.html",
        content = function(file) {
      # Copy the report file to a temporary directory before processing it, in
      # case we don't have write permissions to the current working dir (which
      # can happen when deployed).
          tempReport &lt;- file.path(tempdir(), "report.Rmd")
          file.copy("report.Rmd", tempReport, overwrite = TRUE)
  
      # Set up parameters to pass to Rmd document
          params &lt;- list(n = input$slider)
  
      # Knit the document, passing in the `params` list, and eval it in a
      # child of the global environment (this isolates the code in the document
      # from the code in this app).
          rmarkdown::render(tempReport, output_file = file,
            params = params,
            envir = new.env(parent = globalenv())
          )})}
  
  ui &lt;- fluidPage(
       sliderInput("slider", "Slider", 1, 100, 50),
       downloadButton("report", "Generate report"))
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>However, I cannot download the report (Failed-Server problem) and got error:</p>
  
  <pre><code>Listening on http://127.0.0.1:3638
  Warning in normalizePath(path, winslash = winslash, mustWork = mustWork) :
    path[1]="/tmp/Rtmp1BbjoR/test.Rmd": No such file or directory
  Warning: Error in tools::file_path_as_absolute: file '/tmp/Rtmp1BbjoR/test.Rmd' does not exist
  Stack trace (innermost first):
      58: tools::file_path_as_absolute
      57: dirname
      56: setwd
      55: rmarkdown::render
      54: download$func [example_code/report.R#23]
       5: &lt;Anonymous&gt;
       4: do.call
       3: print.shiny.appobj
       2: print
       1: print
  Error : file '/tmp/Rtmp1BbjoR/test.Rmd' does not exist
  </code></pre>
  
  <p>I am working on R server. Is there any suggestion in terms of this error?</p>
  
  <p>Thanks in advance.</p>