Generating markdown report in shiny?

I do have another issue - which I'm not sure can be replicated.

I have put together below a more simplified version of the initial app. For some reason, when I click on "Generate report", the file created is called "report" when I specified it to be "report.pdf". I end up having to manually change the downloaded file name to add ".pdf" in order for my computer to recognize it as a PDF document. Is anyone else experiencing the same issue? Is there a correction to be made to the below?



  ui = fluidPage(
    sliderInput("slider", "Slider", 1, 100, 50),
    downloadButton("report", "Generate report")
  server = function(input, output) {
    output$report <- downloadHandler(
      filename = "report.pdf",
      content = function(file) {
        tempReport <- file.path(tempdir(), "report.Rmd")
        file.copy("report.Rmd", tempReport, overwrite = TRUE)

        params <- list(n = input$slider)

        render(tempReport, output_file = file,
           params = params,
           envir = new.env(parent = globalenv())


title: "Dynamic report"
output: pdf_document
  n: NA

# The `params` object is available in the document.

A plot of `r params$n` random points.

plot(rnorm(params$n), rnorm(params$n))
1 Like