Bericht erstellen mit Shiny App und Rmarkdown

Ich möchte eine glänzende App erstellen, mit der Sie einen Bericht herunterladen können. Im Moment versuche ich, die Dinge supereinfach zu halten und die einzige Eingabe in der glänzenden App ist ein Text, den der Benutzer mit @ eingeben kantextarea:

library(shiny)
server <- function(input, output) {
  output$downloadReport <- downloadHandler(
    filename = function() {
      paste('my-report', sep = '.', switch(
        input$format, PDF = 'pdf', HTML = 'html', Word = 'docx'
      ))
    },
    content = function(file) {
      src <- normalizePath('report.Rmd')

      # temporarily switch to the temp dir, in case you do not have write
      # permission to the current working directory
      owd <- setwd(tempdir())
      on.exit(setwd(owd))
      file.copy(src, 'report.Rmd', overwrite = TRUE)

      library(rmarkdown)
      out <- render('report.Rmd', switch(
        input$format,
        PDF = pdf_document(), HTML = html_document(), Word = word_document()
      ))
      file.rename(out, file)
    }
  )
}

ui <- fluidPage(
  tags$textarea(id="text", rows=10, cols=80, "Default value"),

  flowLayout(radioButtons('format', 'Document format', c('HTML', 'Word'),
                          inline = TRUE),
             downloadButton('downloadReport'))

)

shinyApp(ui = ui, server = server)

Myreport.Rmd Datei hat nur zwei Zeilen:

# Title

`r renderPrint({ input$text })`

Leider druckt der Bericht nichtinput$text.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage