Shiny tabsetPanel does not display graphs in multiple tabs

I am trying to use multiple controls tabPanelin tabsetPanelin Shiny. Suppose I start with one tab using the following code:

mainPanel(
    tabsetPanel(
    tabPanel("Plot",plotOutput("distPlot"))
    )

The code works fine and displays a graph on the tab.

But at the moment when I entered another tab only for checking tabs, both tabs stop displaying any graphs. I am using the following code:

mainPanel(
    tabsetPanel(
    tabPanel("Plot",plotOutput("distPlot")),
    tabPanel("Plot",plotOutput("distPlot"))
    )

Note that I am trying to display the same graph on both tabs to check if the tabs are working. All I get is two empty tabs (if I use only one tab, the graph displays correctly).

Will anyone help me figure this out?

+4
2

"distPlot" plotOutput outputId. "ID" , . plotOutput, :

runApp( list(

  server = function(input, output) {
    df <- data.frame( x = rnorm(10), y = rnorm(10) )
    output$distPlot1 <- renderPlot({ plot( df, x ~ y ) })
    output$distPlot2 <- renderPlot({ plot( df, x ~ y ) })
  },

  ui = fluidPage( mainPanel(
    tabsetPanel(
      tabPanel( "Plot", plotOutput("distPlot1") ),
      tabPanel( "Plot", plotOutput("distPlot2") )
    )
  ))
))
+7

tabsetPanel(
  tabPanel( "Plot", plotOutput("distPlot1"),plotOutput("distPlot2") )
)
+1

Source: https://habr.com/ru/post/1535472/


All Articles