title: Shiny import data.table and manipulate it
body: <p>I am struggling on manipulating a data table that is imported on a shiny app. Particularly I would like to re-order the columns and delete some. I am trying to do this with the <code>data.table</code> package structure. For the re-ordering I am using <code>sortable::rank_list()</code> and <code>data.table::setcolorder()</code> and I have accomplished it but with the following <code>*Error in setcolorder: dt passed to setcolorder has no names*</code> appearing before the file is imported.</p>
  
  <p>For deleting columns I would like to pass the name of the column to a <code>textInput</code> and only delete when pushing an <code>actionButton</code>. I am trying something like:</p>
  
  <pre><code>observeEvent(input$delete_col, {
   myData()[,input$delete_col_txt := NULL]
  })
  </code></pre>
  
  <p>but no such luck.</p>
  
  <p>Bellow my code and thanks for your time!</p>
  
  <pre><code>
  library(shiny)
  library(data.table)
  library(sortable)
  
  ui &lt;- fluidPage(
  
    titlePanel("Uploading Files in R"),
  
    fluidRow(
      column(4,
          wellPanel(
            navlistPanel(
  
              tabPanel("1. Import",
  
                       fileInput("file1", "Choose CSV File",
                        multiple = FALSE,
                        accept = c("text/csv",
                                "text/comma-separated-values,text/plain",
                                ".csv")),
                        tags$hr(),
                        checkboxInput("header", "Header", TRUE),
                        radioButtons("sep", "Separator",
                                    choices = c(Comma = ",",
                                                Semicolon = ";",
                                                Tab = "\t"),
                                    selected = ","),
                        textInput("nrows", "Rows", value = "Inf"
                                    )
                       ),
  
              tabPanel("2. Manipulations",
                      column(4, uiOutput("delete_column_txt"),
                                uiOutput("delete_column_btn"),),
                      column(8,uiOutput("rank_list_1"))
  
                       )
            )
          )
  
      ),
      mainPanel(
            DT::dataTableOutput('contents')
      )
    )
  
  )
  
  
  server &lt;- function(input, output) {
  
    options(shiny.maxRequestSize=80*1024^3) # Maximum upload size allowed, in bytes
  
    myData &lt;- reactive({
      inFile &lt;- input$file1
      if (is.null(inFile)) return(NULL)
      data &lt;- fread(inFile$datapath, header = input$header, sep = input$sep, nrows = as.numeric(input$nrows))
      return(data)
    })
  
  
    observeEvent(input$file1$datapath,{
  
      output$delete_column_txt &lt;- renderUI({
        textInput("delete_col_txt", "Name of column to delete")
      })
      output$delete_column_btn &lt;- renderUI({
        actionButton("delete_col", "Delete")
      })
      output$rank_list_1 &lt;- renderUI({
            rank_list(
              text = "Set the order of columns",
              labels = as.list(names(myData())),
              input_id = "rank_list_1"
            )
          })
  
     })
  
    output$contents &lt;- DT::renderDataTable({
        setcolorder(myData(), input$rank_list_1)
    })
  
  }
  shinyApp(ui = ui, server = server)
  
  </code></pre>