Q:

How to aggregate a reactive table in shiny?

I am trying to aggregate a reactive table from Shiny. My structure is similar to this example 
library(shiny)

runApp(list(
  ui=pageWithSidebar(headerPanel("Adding entries to table"),
                     sidebarPanel(textInput("text1", "Column 1"),
                                  textInput("text2", "Column 2"),
                                  actionButton("update", "Update Table")),
                     mainPanel(tableOutput("table1"))),
  server=function(input, output, session) {
    values <- reactiveValues()
    values$df <- data.frame(Column1 = NA, Column2 = NA)
    newEntry <- observe({
      if(input$update > 0) {
        newLine <- isolate(c(input$text1, input$text2))
        isolate(values$df <- rbind(values$df, newLine))
      }
    })
    output$table1 <- renderTable({values$df})
  }))

I am trying with several ways, for example:
output$table2 <- renderTable({
  as.data.frame(values$Column1, list(values$Column2), sum
})

But until now I could not have the expected result. Do you have an idea, please?

A:

Are you looking for something like a row sum? I used the apply function with sum, but the
output$table1 <- renderTable({cbind(values$df, Rowsum = apply(values$df, 1, function(x) sum(as.numeric(x))))})

Also, if you would like to remove the first empty line, you could use the advice in the SO question you linked
It looks like this:

Complete code:
library(shiny)

runApp(list(
  ui=pageWithSidebar(headerPanel("Adding entries to table"),
                     sidebarPanel(textInput("text1", "Column 1"),
                                  textInput("text2", "Column 2"),
                                  actionButton("update", "Update Table")),
                     mainPanel(tableOutput("table1"))),
  server=function(input, output, session) {
    values <- reactiveValues()
    values$df <- data.frame(Column1 = numeric(0), Column2 = numeric(0))
    newEntry <- observe({
      if(input$update > 0) {
        newLine <- isolate(c(input$text1, input$text2))
        isolate(values$df[nrow(values$df) + 1,] <- c(input$text1, input$text2))
      }
    })
    output$table1 <- renderTable({cbind(values$df, Rowsum = apply(values$df, 1, function(x) sum(as.numeric(x))))})
  }))

Please note, that there is no exception handling implemented.

