title: Add columns to a reactive data frame in Shiny and update them
body: <p>I would like to be able to calculate a new column of data based on dividing one column by another, with both original columns selected by a user input. I would like to have this calculated data joined to the original table (or a copy of it).</p>
  
  <p>I have managed to figure out how to make a dataframe that reacts to the column input selection, and I have managed to make a calculation that divides one column by the other, but I have not been able to make a final dataframe that includes all of the original columns as well as the new calculated one.</p>
  
  <p>Here is a mock up I have made using the built in Iris data. It displays the data for the columns selected in the first table, and the calculation in the second table (you will need to scroll down quite far to see this).</p>
  
  <p>How can I join this calculated data to the original source?</p>
  
  <p>Many thanks</p>
  
  <pre><code>#Ui        
  pageWithSidebar(
        headerPanel('Calculate Column'),
        sidebarPanel(
  
          #select variables from iris dataset
          selectInput('xcol', 'X Variable', names(iris)),
          selectInput('ycol', 'Y Variable', names(iris),
                      selected=names(iris)[[2]])
        ),
        mainPanel(
          #display the selected variables
              tableOutput("view"),
           #display the calculated variable
              tableOutput("view2")
        )
      )
  
  
  #Server
          function(input, output, session) {
  
        # Combine the selected input variables into a new data frame
        selectedData &lt;- reactive({
          iris[, c(input$xcol, input$ycol),]
        })
  
  
        # divide one variable selection by the other
        selectedData2 &lt;- reactive({
                  iris$new&lt;-iris[, c(input$xcol)]/iris[, c(input$ycol)]
  
          })
  
        # create data output for selected variables
        output$view &lt;- renderTable({selectedData()
        })
  
        # create data output for calculated variable
        output$view2 &lt;- renderTable({selectedData2()
        })
  
      }
  </code></pre>