Reputation: 519
In the following R shiny code below, I am trying to embed two boxes aligned left and right with a selectInput widget above the left box and the entire thing appearing in a bsmodal popup when we click the Button. I am not able to get the desired result however, please help me with the tweak such that I can make it appear upon button click. Thanks
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)
Upvotes: 0
Views: 908
Reputation: 29397
This should do the job:
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)
Upvotes: 2