combining shiny and rmarkdown to generate different reports based on the disease

I need to make a shiny app that generates Rmarkdown report based on the type of disease. And for each disease there are different inputs. I finished the UI part well.

the problem in the server part where when I click the button to generate a report, I need it to take a certain template based on the name of the disease. and in params (renderRmarkdown) I specified different inputs to be generated in the report.

I tried to make ifelse function based on the type of the disease but I get an error to add reactivity or observer

In server part:

output$btn <- downloadHandler(
  filename = function(){"myreport.docx"}, #3awzo ya5od raqam accession
  content = function(file) {
    tempReport <- file.path(tempdir(),"esoApp.Rmd") 
    file.copy("esoApp.Rmd", tempReport, overwrite = TRUE)
    if(input$disease == "Esophagus") {rmarkdown::render("esoApp.Rmd", output_format = "word_document", output_file = file, 
                                                       params = list(A= input$search,
                                                                     A0= input$author,
                                                                     A1 = input$EsophagealCarcinomaProcedure,
                                                                     
                                                                     A3 = input$EsophagealCarcinomaTumorSite), # here I'm passing data in params
                                                       envir = new.env(parent = globalenv()),clean=F,encoding="utf-8"
    )}
    
    ifelse(input$search == "Thyroid"){
      rmarkdown::render("ThyroidApp.Rmd", output_format = "word_document", output_file = file,
                        params = list(A= input$search,
                                      A0= input$author,
                                      A22 = input$ThyroidPredisposingCondition(s),
                                      
                                      A24 = input$PreoperativeSerumMarkerFindings)
                                      envir = new.env(parent = globalenv()),clean=F,encoding="utf-8"
                        )}

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.