Where do I save the Rmd file I am generating with a Shiny R App

For the path you are using, the Rmd file should be in the root folder of your app (the same where the app.R file is located).

Doing this, especially on a Shiny app is a bad idea, the app is going to fail on deployment.
A better workflow would be to create a project for your app, that way you don't need to manually set the working directory.

This simple example works for me

library(shiny)
library(markdown)

ui = fluidPage(
  textInput("year", "Enter Year"),
  downloadButton("report", "Generate report")
)
server <- function(input, output, session) {
  output$report <- downloadHandler(
    filename = "report.html",
    content = function(file) {
      params <- list(year = input$year)
      
      rmarkdown::render("report.Rmd", 
                        output_file = file,
                        params = params,
                        envir = new.env(parent = globalenv())
      )
    }
  )
}

shinyApp(ui, server)

report.Rmd

---
title: "Test"
output: html_document
params:
  year: "2020"
---

```{r}
params$year
```

Rendered report

1 Like