![](/img/trans.png)
[英]In R Shiny, how to move user inputs from sidebar panel into a modal dialogue box?
[英]In R shiny how to move table and related inputs, generated using rhandsontable, into a modal dialogue box?
我對 rhandsontable 包和 R 中模態對話的使用非常陌生,但在模態對話框中渲染反應表對於我運行的模型類型非常重要。 我需要學習如何做好這件事!
舉例來說,下面的 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 代碼時會出現什么:
我想做什么:
也許你正在尋找這個
library(shiny)
library(rhandsontable)
ui <- shinyUI(fluidPage(
h4("Click ´Show´ button below to trigger modal dialogue:"),
#tags$head(tags$style(" .modal-dialog{ width:800px}")),
tags$head(tags$style(" .modal-body{ min-height:500px}")),
actionButton("show","Show"),
br(),br()
))
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)
observeEvent(input$show, {
showModal(modalDialog(title = "my display",
actionButton(inputId = "reset_input", label = "Reset"),
br(),br(),
rHandsontableOutput("two_by_two"),
br(),
tableOutput(outputId = "chg_data"),
easyClose = TRUE, footer = NULL, class = 'success'
))
})
})
shinyApp(ui, server)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.