How to pass a CSV file from shiny to rmarktdown to generate html report based on a user input?

Error in read.table: object 'params' not found
[No stack trace available]

server.R

shinyServer(function(input, output) {

output$report <- downloadHandler(
    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 <- file.path(tempdir(), "report.Rmd")
      file.copy("report.Rmd", tempReport, overwrite = TRUE)
      
      # Set up parameters to pass to Rmd document
      infile4 <- input$cleanedFile
      params <- list(n = infile4$datapath)
        
        rmarkdown::render(tempReport, output_file = file,
                          params = params,
                          envir = new.env(parent = globalenv())
        )
      
    }
  )
  
})

.Rmd

---
title: |
  | \vspace{5cm} 

output:
  html_document:
    toc: yes
    toc_depth: 2
    toc_float: True
    number_sections: true
    
params:
  n: NA 

---
```{r global, include=FALSE}

screeningData = read.csv(file = params$n, sep = ",")



```

is there a question here?

Yes, I can't figure out how to pass a csv file from shiny to rmarkdown as a param

Sh***. I found it. I should have passed it as character...

params:
n: ""

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.