【发布时间】:2019-07-15 15:29:12
【问题描述】:
我有一个闪亮的应用程序,其中一项功能是允许用户编辑表中的值,当单击运行时,它将使用用户输入作为函数的值,然后更新同一个表中的结果.下面是当前表和预期表的示例。因此,在第一个表中,如果用户更改通道 A 和 C 的电流值并单击运行,它应该将自身更新为表 预期输出中反映的值。
所以我的问题是,是否可以将可编辑的 DT 值作为函数的输入。
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(
DT::dataTableOutput("x1"),
actionButton("opt_run", "Run"),
tags$h1("Expected Output"),
DT::dataTableOutput("x2")
),
server = function(input, output, session) {
df <- data.table(Channel = c("A", "B","C"),
Current = c("2000", "3000","4000"),
Modified = c("2500", "3500","3000"),
New_Membership = c("450", "650","700"))
output$x1 = renderDT(df, selection = 'none', editable = TRUE)
expdf <- data.table(Channel = c("A", "B","C"),
Current = c("3000", "3000","5000"),
Modified = c("3500", "3500","6000"),
New_Membership = c("650", "650","1100"))
output$x2 = renderDT(expdf, selection = 'none', editable = TRUE)
})
}
)
【问题讨论】: