title: R Shiny - Reactive dataframe download to csv
body: <p>I have produced an app that allows the user to upload multiple csv files. </p>
  
  <p>These csvs then 'rbind' together, 'read.csv' and have a column added to the df which is the filename. </p>
  
  <p>The df is then processed to produce various plots which are downloadable.  This works perfectly. However when I try download a specific data frame from within the reactive element I can't get it to work. </p>
  
  <p>In this example I want to download <strong>df1</strong> from within the testinput reactive function.</p>
  
  <p>UI:</p>
  
  <pre><code>    dashboardPage( skin = "black",
     dashboardHeader(title = "myApp"),
     dashboardSidebar(collapsed = TRUE,
     sidebarMenu(
      menuItem("Home", tabName = "dashboard1", icon = icon("home", lib = 
    "glyphicon"))
      ) 
      ),
     dashboardBody(
       tags$head(tags$style(HTML('
        .main-header .logo {
                            font-family: "Times New Roman", serif;
                            font-weight: bold;
                            font-size: 24px;
                            }
                            '))),
  
  tabItems(
    tabItem(tabName = "dashboard1",
            fileInput("file1",
                      label="Input files:",
                      multiple = TRUE),
            downloadButton('downloadData', 'Download Data')
    )
    )
  
  )
  )
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>     library(shiny)
       library(shinydashboard)
  
       #server start
       function(input, output) {
  
         testinput&lt;- reactive({
  if(is.null(input$file1))
    return ()
  else 
  {
    nfiles = nrow(input$file1) 
    csv = list()
    for (i in 1 : nfiles)
    {
  
      csv[[i]] = read.csv(input$file1$datapath[i])
  
    }
  
    csv_names &lt;- input$file1[['name']]
      actual_names&lt;-input$statics$name
    df1&lt;-cbind(actual_names, csv_names)
    mydata &lt;- do.call(rbind, lapply(csv_names, function(x) cbind(read.csv(x), name=strsplit(x,'\\.')[[1]][1])))
      df1&lt;-cbind(df1, mydata)    
    }
     })
  
       output$downloadData &lt;- downloadHandler(
  filename = function() { paste(input$downloadData, " ",Sys.Date(),".csv",sep="") },
  content = function(file) {
    write.csv(df1,file)
  }
      )
  
   )
  
  
     }
  </code></pre>
  
  <p>Any help would be great as I have searched lots of SO and other forums and I'm pretty stuck.</p>