使多个 R 闪亮小部件出现在弹出窗口中

Making multiple R shiny widgets appear in a popup

在下面的 R 闪亮代码中,我试图嵌入两个左右对齐的框,左侧框上方有一个 selectInput 小部件,当我们单击按钮时,整个内容都会出现在 bsmodal 弹出窗口中。但是,我无法获得所需的结果,请帮助我进行调整,以便我可以在单击按钮时显示它。谢谢

library(DT)
library(shiny)
library(shinyBS)

ui <- basicPage(
h2("The mtcars data"),
column(5,offset = 5,actionButton("CR1_S1", "Button")),
mainPanel(
bsModal("modalExample", "Your Table", "CR1_S1", size = 
"large",uiOutput("mytable"))))
server <- function(input, output) {
output$mytable <- renderUI({
selectInput("variable", "Variable:",
            c("Cylinders" = "cyl",
              "Transmission" = "am",
              "Gears" = "gear"))
box(
  title = "Title 1", width = NULL, solidHeader = TRUE, status = "primary",
  plot(iris$Sepal.Length))
box(
  title = "Title 2", width = NULL, solidHeader = TRUE, status = "primary",
  plot(iris$Petal.length))})
}
shinyApp(ui, server)

这应该可以完成工作:

library(DT)
library(shiny)
library(shinyBS)
library(shinydashboard)

ui <- basicPage(
  h2("The mtcars data"),
  column(5,offset = 5,actionButton("CR1_S1", "Button")),
  mainPanel(
    bsModal("modalExample", "Your Table", "CR1_S1", size = "large",uiOutput("mytable"))))

server <- function(input, output,session) {

  output$plot1 <- renderPlot({
    plot(iris$Sepal.Length)
  })

  output$plot2 <- renderPlot({
    plot(iris$Petal.Length)
  })

  output$mytable <- renderUI({
    tagList(
      selectInput("variable", "Variable:",c("Cylinders" = "cyl","Transmission" = "am","Gears" = "gear")),
      column(6,
      box(
        title = "Title 1", width = NULL, solidHeader = TRUE, status = "primary",
        plotOutput("plot1"))),
      column(6,box(
        title = "Title 2", width = NULL, solidHeader = TRUE, status = "primary",
        plotOutput("plot2")))
    )
  })
}
shinyApp(ui, server)