title: Interactively renaming columns in Rshiny
body: <p>I am pulling a large data set from several sources, and need to rename some of the columns before saving data for further processing.  Given below is a representative R script I have so far. I need advice on how to rename the column interactively.</p>
  
  <pre><code>library(shiny)
  library(DT)
  
  mtcars
  write.csv(mtcars, "mtcars.csv", row.names = T)
  ui &lt;- shinyUI(fluidPage(
    title = "Rename Column",
    sidebarLayout(
      sidebarPanel(
        numericInput("Cylinder","Enter Cylinder", 8, min = 4, max = 12),
        actionButton("process", "Filter Data", style = "color: #fff; background-color: FORESTGREEN; border-color: #2e6da4"),
        tags$br(),tags$br(),
        selectInput(inputId = "OldColumnName", label = "Select Column Name to rename",multiple = F, choices = c("Nil"), selected = ""),
        textInput(inputId = "NewColumnName", label = "Enter New Column Name", "Nil"),
        actionButton("RenameColumn", "Rename Column",style = "color: #fff; background-color: MAROON; border-color: #2e6da4"),
        width = 3),
  
      mainPanel(wellPanel(
        tabsetPanel(type = "pills",  tabPanel("Data Table", 
                     DT::dataTableOutput("ResultsTable", width = "auto", height = "auto"),
                     style = "overflow-y:scroll; max-height: 900px")
        ))) 
      )))
  
  server &lt;- function(input,session, output){session$onSessionEnded(stopApp)
  
    df &lt;- eventReactive(input$process, { 
          df &lt;- data.frame(read.csv("mtcars.csv", header = T) )
          subset(df, df$cyl == input$Cylinder)
    })
  
    output$ResultsTable &lt;- DT::renderDataTable({ 
      df &lt;- df()
      if (!is.null(input$RenameColumn) &amp; (input$NewColumnName != "Nil" | !is.null(input$NewColumnName))) 
         {names(df)[names(df) == input$OldColumnName] &lt;- input$NewColumnName}
      updateSelectInput(session, "OldColumnName", choices = colnames(df), selected = NULL)
      DT::datatable(df)
    })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>