我想從Shiny聚合一個反應表。我的結構類似於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})
}))
我試圖用多種方法,例如:
output$table2 <- renderTable({
as.data.frame(values$Column1, list(values$Column2), sum
})
但是到現在爲止我也沒有預期的結果。你有想法嗎?
抱歉的版本。這是我第一次來... –
預期的結果是什麼?這只是添加值?或添加第二個表? – Geovany
添加第二個包含彙總值的表格。 例如,如果第1列是數字,而第2列是在條目的一欄中從A到E的字母。然後例如按字母(函數和)聚合一列。 –