How to use the download button in Shiny?

Viewed 11934

I want to download a csv file using the download button in Shiny. The file would be created using the parameters from a secondary r script.

    ###SERVER
    output$downloadData <- downloadHandler({
    filename = function() {
        paste('data-', Sys.Date(), '.csv', sep='')
      }
      content = function(file) {
        csv_write<-array(0,dim=c(length(GHI_D),15))
        csv_write<-cbind(GHI_Data$timeStamp,GHI_D,POA_OBS_T,POA_model_T,POA_model_FT,POA_OBS,DNI_model,DHI,tracking_angle,incidence_angel_T,Backtracking_angle,SunAz,SunEl,Kt,DNI,DDNI,incidence_angel,DHI_model,DHI_model_T,Eb,Eb_T)
        write.csv(csv_write,row.names=FALSE, na="")
        write.csv(csv_write,row.names=FALSE, na="")
      }
  })
    ### UI
          downloadButton('downloadData', 'Download CSV Report', style="display: block; margin: 0 auto; width: 230px;color: black;")
1 Answers
Related