[英]Making multiple R shiny widgets appear in a popup
在下面的以下R闪亮代码中,我试图将两个框左右对齐,并在左框上方放置一个selectInput小部件,并且当我们单击Button时,整个内容会出现在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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.