0
library(shiny)
library(plyr)

shinyServer(function(input, output){

  myfile<-reactive({
#reading 3 csv files and merging them into a dataframe
  })

  output$downloadData<-downloadHandler(

    filename = function(){

      paste("mergedfile","csv",sep='.')
    },

    content= function(file){
      write.csv(myfile(),file,sep=",")
    }
  )

})

I am reading 3-4 files reactively and then merging them. After that without displaying them I need to download the merged file.

I wrote the above code but a dialog box opens which asks me where to save but the file doesn't get saved. Am I doing something wrong with the download handler.

ui.R

downloadButton('downloadData','Download')

This is what I have in my main panel in ui.R file

codemob
  • 51
  • 6

1 Answers1

2

Your probably using the Rstudio viewer to run the app? Open the app in your browser and your code will work ( click open in borwser or run runApp('/path/to/myApp',launch.browser=T) ).

See this link.

Also no need to set sep="," for write.csv since this is the default.

Community
  • 1
  • 1
RmIu
  • 4,357
  • 1
  • 21
  • 24
  • Oskar, this worked like a charm in the browser. I would have never guessed that. And your link was helpful too. Thank you! – codemob Nov 25 '15 at 14:17