【发布时间】:2021-10-01 02:33:31
【问题描述】:
我对 rhandsontable 包和 R Shiny 中模态对话的使用非常陌生,但是在模态对话框中渲染反应表对于我运行的模型类型非常重要。我需要学习如何做好这件事!
下面的 MWE 生成一个简单的响应式表,它的工作方式类似于我经常使用的表类型,例如。运行时,如何将当前显示在“显示”操作按钮下方的所有项目移动到模式对话框中?
下面的图片也显示了我正在尝试做的事情。
MWE 代码:
library(shiny)
library(rhandsontable)
ui <- shinyUI(fluidPage(
h4("Click ´Show´ button below to trigger modal dialogue:"),
actionButton("show","Show"),
br(),br(),
actionButton(inputId = "reset_input", label = "Reset"),
br(),br(),
rHandsontableOutput("two_by_two"),
br(),
tableOutput(outputId = "chg_data")
))
server <- shinyServer(function(input, output, session) {
DF <- data.frame(A = c(1, 2), B = c(3, 4), row.names = c("C", "D"))
output$two_by_two <- renderRHandsontable({
input$reset_input # trigger rendering on reset
rhandsontable(DF)
})
output$chg_data = renderTable({
hot_to_r(req({input$two_by_two}))*2}, rownames = TRUE)
})
shinyApp(ui, server)
运行此 MWE 代码时会出现什么:
我想做的事:
【问题讨论】:
标签: r shiny modal-dialog rhandsontable