Download text and generate txt file in Shiny

Viewed 3267

I am looking for a way to download text displayed on an app by generation a .txt file. Here is my attempt, with no success unfortunately:

library(shiny)

ui <- fluidPage(

    sidebarPanel(
      h4("Title"),
      p("Subtitle",
        br(),"Line1",
        br(),"Line2",
        br(),"Line3"),

      downloadButton("Download Metadata", label = "Download")
    )
  )

server <- function(input, output, session){

    output$downlaodData <- downloadHandler(
      filename = function(){
        paste("data-", Sys.Date(), ".txt", sep = "")
      },
      content = function(file) {
        write.txt(data, file)
      }
    )

Thank you for your help

1 Answers
Related