inst/examples/10_download/server.R

function(input, output) {
  datasetInput <- reactive({
    switch(input$dataset,
           "rock" = rock,
           "pressure" = pressure,
           "cars" = cars)
  })
  
  output$table <- renderTable({
    datasetInput()
  })
  
  output$downloadData <- downloadHandler(
    filename = function() { 
		 paste(input$dataset, '.csv', sep='') 
	 },
    content = function(file) {
      write.csv(datasetInput(), file)
    }
  )
}
ymd526442121/Rproject_shiny documentation built on May 4, 2019, 5:31 p.m.