Upgrade to new Gitlab Version 13.9 on Saturday 19th April 20:00. Expect an interruption of about 30 to 60 minutes

downCSV.R 788 Bytes
Newer Older
dmattek's avatar
dmattek committed
1 2 3 4
#
# Time Course Inspector: Shiny app for plotting time series data
# Author: Maciej Dobrzynski
#
dmattek's avatar
dmattek committed
5
# This module is for downloading CSV with data
dmattek's avatar
dmattek committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#
# Usage:
# in ui.R
# downCSV('uniqueID', "your_label")
#
# in server.R
# callModule(downCSV, "uniqueID", 'fname.csv', input_data_to_save)

# UI-download-csv ----
downCsvUI <- function(id, label = "Download Data") {
  ns <- NS(id)
  
  tagList(
    # Label to display as h4 header
    h4(label),
    downloadButton(ns('downCellCl'), 'CSV')
  )
}

# SERVER-download-csv ----
downCsv <- function(input, output, session, in.fname, in.data) {
  
  output$downCellCl <- downloadHandler(
    filename = function() {
      in.fname
    },
    
    content = function(file) {
      write.csv(x = in.data, file = file, row.names = FALSE)
    }
  )
  
}