title: R change columns types using shiny, rhandson and DT
body: <p>I have a shiny app, where a user can upload his csv into <code>user_table()</code> 
  reactive expression, which is then shown to a user using DT <code>renderDataTable()</code>;
  There is also RHandsontable with the types of columns from <code>user_table()</code>. User should be able to change the values in RHandsontable and click 'Apply' button, to apply changes to his table. (i.e. there is a 'number' column, and he wants to change it into 'character'). 
  Here is how DT is rendered for a user:</p>
  
  <pre><code>main_table &lt;- DT::renderDataTable({
      datatable(
          user_table()
      )
  })
  </code></pre>
  
  <p>Here is how handsontable works:</p>
  
  <pre><code>dataTypes &lt;- c("integer", "numeric", "factor", "character", "logical")
  handsontable &lt;- renderRHandsontable({
      if (!is.null(input$uploaded_file)) {
          if (is.null(input$hottest)) {
              DF = data.frame(Type = cbind(lapply(user_table(), typeof)),
                              stringsAsFactors = TRUE)
          } else {
              DF = hot_to_r(input$hottest)
          }
          DF$Type = factor(DF$Type, dataTypes)
          rhandsontable(DF, readOnly = FALSE) %&gt;%
              hot_table(stretchH = 'all', rowHeaderWidth = 120) %&gt;%
              hot_context_menu(allowRowEdit = FALSE, allowColEdit = FALSE)
      }
      else { return() }
  })
  </code></pre>
  
  <p>Now I'm trying to do the following: after the apply button click, make a new table with user-changed types of columns, though I'm not sure how should it be done correctly. Should I use another reactive expression to do that? Is observeEvent the right thing to use for button onclick event? If something is unclear, please ask. Thanks in advance!</p>
  
  <p>edit: I've come up with this function after browsing SO for some time:</p>
  
  <pre><code>convert.types &lt;- function(obj, types){
          for(i in length(obj)){
              func &lt;- switch(types[i],
                             integer = as.integer,
                             numeric = as.numeric,
                             factor = as.factor,
                             character = as.character,
                             logical = as.logical)
              obj[,i] &lt;- func(obj[,i])
          }
          obj
      }
  </code></pre>
  
  <p>and use it with observeEvent:</p>
  
  <pre><code>observeEvent(input$button_table_convertion, {
      hottestVector &lt;- as.vector(t(hot_to_r(input$hottest)))
      new_table &lt;- convert.types(as.data.frame(user_table()), hottestVector)
  </code></pre>
  
  <p>Although, Rhandsontable is not reacting to user input; it just changes columns types to the same they've been already. Any workaround?</p>