Shiny deployment with RMD

Hi,

I am facing an issue while deploying my Shiny app, which is designed to export a PDF based on an .Rmd file. The Shinyapps.io log indicates that it cannot find the object 'params'.

When running the app on my local computer, everything works perfectly. Below is a portion of the code that is related to the problem. Please note that all of the "params" are reactive values. Can you help me identify what might be causing the issue?

map_category_to_text <- function(value) {
    categories <- c("Daily Commuting", "Office & Work", "Business Travel", "Hotel Stays", "Food")
    return(categories[value])
  }
  
  output$download_pdf <- downloadHandler(
    filename = function() {
      paste("report-", Sys.Date(), ".pdf", sep = "")
    },
    content = function(file) {
      # Extract current values from your reactive functions
      totEm_food <- total_food_emissions()
      totEm_hotel <- total_hotel_stays_emissions()
      totEm_business <- total_business_travel_emissions()
      totEm_work <- total_office_work_emissions()
      totEm_commuting <- total_commuting_emissions()
      totEm_total <- totEm_food + totEm_hotel + totEm_business + totEm_work + totEm_commuting 
      
      # Get the number of employees from the input
      num_employees <- input$employees
      
      # Calculate emissions per employee
      emissions_per_employee <- list(
        total_commuting_e = totEm_commuting / num_employees,
        total_work_e = totEm_work / num_employees,
        total_business_e = totEm_business / num_employees,
        total_hotel_e = totEm_hotel / num_employees,
        total_food_e = totEm_food / num_employees,
        total_total_e = totEm_total / num_employees
      )
      
      # Create a named list of parameters
      params <- list(
        ngo_name = input$organization_name,
        num_employees = num_employees,
        time_period = input$time_period,
        total_commuting_l = totEm_commuting,
        total_work_l = totEm_work,
        total_business_l = totEm_business,
        total_hotel_l = totEm_hotel,
        total_food_l = totEm_food,
        total_total_l = totEm_total,
        emissions_per_employee = emissions_per_employee
      )
      
      # Pass these values as params to the Rmd
      rmarkdown::render("RMD_file2.Rmd",
                        output_file = file,
                        params = params  # Use the 'params' argument to pass the named list
      )
    }
  )

Part of the .Rmd file:

---
title:
output:
  pdf_document:
    keep_tex: true
    
header-includes:
  - \usepackage{graphicx}
  - \usepackage{helvet}  # Add the helvet package to use Helvetica font
  - \renewcommand\familydefault{\sfdefault}  # Set the default font to sans-serif (Helvetica)
---

\begin{center}
\includegraphics[width=5cm]{logo1.jpg}

\textbf{\Large Sustainable NGOs: Carbon Footprint Calculator}
\end{center}

\begin{center}
\section*{Carbon Footprint Report}
Date: \today
\end{center}

\raggedright
### 1. Metadata

Details about the organisation and its calculation:

- Organisation: `r params$ngo_name`
- Number of employees: `r params$num_employees`
- Calculation for the time period: `r format(params$time_period[1], "%d.%m.%Y")` - `r format(params$time_period[2], "%d.%m.%Y")`

### 2. Results

| Category               | Total carbon Emissions (kg CO2e) | Emissions per Employee (kg CO2e) |
|------------------------|---------------------------------|---------------------------------|
| Daily Commuting        | `r round(params$total_commuting_l, 2)` | `r round(params$emissions_per_employee$total_commuting_e, 2)` |
| Office & Work             | `r round(params$total_work_l, 2)` | `r round(params$emissions_per_employee$total_work_e, 2)` |
| Business Travel  | `r round(params$total_business_l, 2)` | `r round(params$emissions_per_employee$total_business_e, 2)` |
| Hotel Stay       | `r round(params$total_hotel_l, 2)` | `r round(params$emissions_per_employee$total_hotel_e, 2)` |
| Food   | `r round(params$total_food_l, 2)` | `r round(params$emissions_per_employee$total_food_e, 2)` |
|------------------------|---------------------------------|---------------------------------|
| Total Emissions        | `r round(params$total_total_l, 2)`| `r round(params$emissions_per_employee$total_total_e, 2)` |