我在下面有闪亮的应用程序,我有一个 tabPanel()
子面板。我希望默认情况下显示两个图。然后,如果用户按 SUBTAB 1
则仅显示要显示的左图。如果他再次按下 SUBTAB 1
,两者都会再次显示。 SUBTAB 2
和右图的逻辑相同。
library(shiny)
ui <- fluidPage(
titlePanel("Explore Data"),
tabsetPanel(
tabPanel("tabPanel 1",
tabsetPanel(
tabPanel("SUBTAB 1",
fluidRow(
column(width = 6,
plotOutput("Plot1", height = "350px")
)
)
),
tabPanel("SUBTAB 2",
fluidRow(
column(width = 6,
plotOutput("Plot2", height = "350px")
)
)
)
) #Close inner tabsetPanel
)
) #Close outer tabsetPanel
) #Close FluidPage
server <- function(input, output) {
output$Plot1 <- renderPlot({
plot(seq(0,10), seq(100, 110), col = "red")
})
output$Plot2 <- renderPlot({
plot(seq(0,10), seq(0, 10)^2, type = "b")
})
}
# Run the application
shinyApp(ui = ui, server = server)