Can someone please point out how I can make this download zip function work in server.R? When I run this, I get the following error:
- [1] "/var/folders/00/1dk1r000h01000cxqpysvccm005p87/T//Rtmps3T6Ua"
- Warning in write.csv(datasetInput()$rock, file = "rock.csv", sep = ",") : attempt to set 'sep' ignored
- Warning in write.csv(datasetInput()$pressure, file = "pressure.csv", sep = ",") : attempt to set 'sep' ignored
- Warning in write.csv(datasetInput()$cars, file = "cars.csv", sep = ",") : attempt to set 'sep' ignored
- [1] "rock.csv" "pressure.csv" "cars.csv"
- adding: rock.csv (deflated 54%)
- adding: pressure.csv (deflated 42%)
- adding: cars.csv (deflated 57%)
- Error opening file: 2
Error reading: 9
library(shiny) # server.R server <- function(input, output) { datasetInput <- reactive({ return(list(rock=rock, pressure=pressure, cars=cars)) }) output$downloadData <- downloadHandler( filename = 'pdfs.zip', content = function(fname) { tmpdir <- tempdir() setwd(tempdir()) print(tempdir()) fs <- c("rock.csv", "pressure.csv", "cars.csv") write.csv(datasetInput()$rock, file = "rock.csv", sep =",") write.csv(datasetInput()$pressure, file = "pressure.csv", sep =",") write.csv(datasetInput()$cars, file = "cars.csv", sep =",") print (fs) zip(zipfile=fname, files=fs) }, contentType = "application/zip" ) } # ui.R ui <- shinyUI(fluidPage( titlePanel('Downloading Data'), sidebarLayout( sidebarPanel( downloadButton('downloadData', 'Download') ), mainPanel() ) ) ) shinyApp(ui = ui, server = server)