title: Load, edit, and download a csv file in shiny
body: <p>I am trying to load a csv file to a shiny program, edit it in place and download the edited file. I found that the package <code>DT</code> provides some functionalities for the same. I modified the <a href="http://shiny.rstudio.com/gallery/upload-file.html" rel="nofollow noreferrer">example here</a> to read csv from the file and <a href="https://yihui.shinyapps.io/DT-info/" rel="nofollow noreferrer">example here</a> to write the output. I was also trying to edit the loaded CSV in place using the DT's experimental features <a href="https://github.com/rstudio/DT/issues/28" rel="nofollow noreferrer">here</a>. My code below loads csv, and saves the CSV but while trying to edit it in place it crashes with the error:  </p>
  
  <pre><code>Warning: Error in &lt;&lt;-: invalid (NULL) left side of assignment
  Stack trace (innermost first):
  65: observeEventHandler [/home/user/ShinyApp/EditingValues/server.R#40]
  </code></pre>
  
  <p>Basically, my problem I believe I am not able to provide values to x from the read csv in the <a href="https://github.com/rstudio/DT/issues/28" rel="nofollow noreferrer">example here</a>.</p>
  
  <p>My <code>ui.R</code> is</p>
  
  <pre><code>fluidPage(
    titlePanel("Uploading Files"),
    sidebarLayout(
      sidebarPanel(
        fileInput('file1', 'Choose file to upload',
                  accept = c(
                    'text/csv',
                    'text/comma-separated-values',
                    'text/tab-separated-values',
                    'text/plain',
                    '.csv',
                    '.tsv'
                  )
        ),
        tags$hr(),
        checkboxInput('header', 'Header', TRUE),
        radioButtons('sep', 'Separator',
                     c(Comma=',',
                       Semicolon=';',
                       Tab='\t'),
                     ','),
        radioButtons('quote', 'Quote',
                     c(None='',
                       'Double Quote'='"',
                       'Single Quote'="'"),
                     '"'),
        tags$hr(),
        p('Once you are done download the  data'),
        downloadButton('x3', 'Download Data')
      ),
      mainPanel(
          DT::dataTableOutput('x1')
      )
    )
  )
  </code></pre>
  
  <p>My <code>server.R</code> is</p>
  
  <pre><code># By default, the file size limit is 5MB. It can be changed by
  # setting this option. Here we'll raise limit to 9MB.
  
  # Install DT, experimental version may not work well 
  # devtools::install_github('rstudio/DT@feature/editor')
  
  library(shiny) # The main program
  library(DT) # Edit the output
  library(data.table) # Faster read and write
  
  options(shiny.maxRequestSize = 9*1024^2)
  
  function(input, output, session) {
     dataframe&lt;-reactive({
          if (is.null(input$file1))
              return(NULL)  
         dta_types = fread(input$file1$datapath, header = input$header,
                           sep = input$sep, quote = input$quote, nrows = 0,
                           strip.white = TRUE, data.table = FALSE)
          data&lt;-fread(input$file1$datapath, header = input$header,
                      sep = input$sep, quote = input$quote,
                      stringsAsFactors = FALSE, colClasses= rep("character", ncol(dta_types)))
          data
      })
  
    output$x3 = downloadHandler('mtcars-filtered.csv', content = function(file) {
        s = input$x1_rows_all
        write.csv(dataframe()[s, , drop = FALSE], file)
    })
    output$x1 = DT::renderDataTable(dataframe(), selection = 'none')
  
    proxy = dataTableProxy('x1')
  
    observeEvent(input$x1_cell_edit, {
        info = input$x1_cell_edit
        str(info)
        i = info$row
        j = info$col
        v = info$value
        dataframe()[i, j] &lt;&lt;- DT:::coerceValue(v, dataframe()[i, j])
        replaceData(proxy, dataframe(), resetPaging = FALSE)
    })
  }
  </code></pre>
  
  <p>How can this be achieved? I am sure I missing simple assignment somewhere. I tried </p>
  
  <pre><code>x=dataframe() 
  </code></pre>
  
  <p>before </p>
  
  <p>output$x1 = DT::renderDataTable(dataframe(), selection = 'none')</p>
  
  <p>and using x instead of dataframe() everywhere but that crashes the app before it is loaded. Thanks for the inputs.
  A <a href="https://stackoverflow.com/questions/33722757/update-handsontable-by-editing-table-and-or-eventreactive">similar</a> question using <code>rhandsontable</code> also does not have an answer yet.</p>