Rshiny output is duplicated on both tab panels

I added a new tabItem to the shiny application with two tab panels. One is supposed to display a table as an output and the other 3 plots. However, plots are duplicated on the first tab with table page as well. I tried to play with column numbers and fluid rows but nothing works so far.

ui.R

tabItem(
    
    tabName = "sddesktop",
        
    div(style="display:inline-block;vertical-align:center;",
    
      fluidRow(
      column(3, offset = 0,
             box(title = "Sensitive Data usage reports",
                 width = NULL,
                 solidHeader = FALSE,status="warning"))),
      #column(6, uiOutput(outputId = "datesinc", style = "padding: 0px 0px;")),
      column(1, offset = 8,
             actionButton( # shinyWidgets
               inputId = "sddesktop_usage_back",
               label = NULL,
               icon = icon("rotate-left", lib = "font-awesome")
             )
      ),
      
      br(), br(),
              
                
                fluidRow(class = "select-to-top", column(2,offset=0,
                                                         # Choose years
                                                         div(style = "padding: 0px 0px; margin-top:1em;",
                                                             pickerInput(inputId = "year_selector", 
                                                                         choices = c("2019","2020","2021","2022"),
                                                                         selected = "2022",
                                                                         label = NULL,
                                                                         multiple = TRUE,
                                                                         options = list(style= "ida-class",
                                                                                        title = "Select year")
                                                             ))
                )
                ),
                
          br(),
          
          
          fluidRow(
            column(
              12, offset = 0,
              
              fluidRow(
                
                tabBox(
                  #title = "SD Desktop usage",
                  width = 12,
                  
        
              tabPanel(
                    "Usage table",
                    value = "sdpanelval",
                    icon = icon("cloud"),
                    
                    br(),
                    
                    fluidRow(
                      
                      column(
                        2, 
                        checkboxGroupButtons(
                          inputId = "sddatausage_select_status",
                          label = h4("Projects status"),
                          choices = c("open","closed"),
                          selected = c("open","closed"),
                          status = "success",
                          individual = TRUE,
                          # width = '50%',
                          checkIcon = list(
                            yes = icon("ok",
                                       lib = "glyphicon")
                          )
                        )
                        
                      ),
                      
                      column(
                        4,  
                        checkboxGroupButtons(
                          inputId = "sddatausage_select_scope",
                          label = h4("Projects scope"),
                          choices = c("internal","academic"),
                          selected  = c("internal","academic"),
                          status = "success",
                          individual = TRUE,
                          # width = '50%',
                          checkIcon = list(
                            yes = icon("ok",
                                       lib = "glyphicon")
                          )
                        )
                        
                      ),
                      
                      column(
                        2,  
                        
                        radioGroupButtons(
                          inputId = "sddatausage_individualusers",
                          label = h4("Individual users"),
                          choices = c("Yes","No"),
                          selected = "No",
                          status = "success",
                          individual = TRUE,
                          # width = '50%',
                          checkIcon = list(
                            yes = icon("ok",
                                       lib = "glyphicon")
                          )
                        )
                        
                      )
                    ),
                    column(
                      2, 
                      pickerInput(
                        inputId = "fl_selector",
                        label = "Virtual Machine", 
                        choices = c("standard.xxlarge","standard.xlarge","standard.medium","standard.tiny","hpc.4.40core"),
                        multiple = TRUE
                      )
                    ),
                    
                    br(),
                    
                    fluidRow(
                      
                      column(
                        12,
                        
                        DT::dataTableOutput("sddesktop_usage_table")
                        
                      )
                      
                    )
                    
                  ),
                  ## Visualisations tab 
                  
     
      tabPanel("Visualizations",
                    value = "sdpanelval2",
                    icon = icon("images"),
        fluidRow(
                 column(
                   6,
                   pickerInput(
                     inputId = "sddatausage_plot_prscope",
                     label = h4("Project scope"), 
                     choices = c("internal","academic"),
                     selected = "academic",
                     multiple = TRUE)
                 )
               ),
        fluidRow(
                column(
                     6,
              pickerInput(
              inputId = "sddatausage_plot_flavourname",
              label = h4("Flavour name"), 
              choices = c("standard.xxlarge","standard.xlarge","standard.medium","standard.tiny","hpc.4.40core"), #character(0) ?
              multiple = TRUE)))
      )
              ),
      
                   
             fluidRow(
                 column(
                   6,
                   plotlyOutput("sddatausage_plot_org")),
                 
                 column(
                   6,
                   plotlyOutput("sddatausage_plot_proj")),
               
                 column(
                 6,
                 plotlyOutput("sd_users_plot"))
             )
                 ),      
                
      
      br()         

                
                )
              )
            )
          )

server.R

observe({
  updatePickerInput(session = session,
                    inputId = "year_selector",
                    choices = sddekstop_projects()$year %>% unique(), selected = sddekstop_projects()$year %>% unique()
  )
})

sddekstop_projects_flavnames <- reactive({
  sddekstop_projects() %>% 
    mutate(flavor = strsplit(as.character(flavor), " ; ")) %>% 
    unnest(flavor)
})

  choices_prjscopes <- reactive({
    cscprjscopes <- sddekstop_projects_flavnames()$cscprjscope %>% unique()
    cscprjscopes
  })
  

  observe({
    updateCheckboxGroupButtons(session = session,
                               inputId = "sddatausage_select_scope",
                               choices = choices_prjscopes(), selected = choices_prjscopes(),
                               status = "success",
                               checkIcon = list(
                                 yes = icon("ok",
                                            lib = "glyphicon"))
    )
  })
  
  
  choices_flavours <- reactive({
    flavours_vm <- sddekstop_projects_flavnames()$flavor %>% unique()
    flavours_vm
  })
  
  observe({
    updatePickerInput(session = session,
                      inputId = "fl_selector",
                      choices = choices_flavours(), selected = choices_flavours())
    
  })
  
  #observe({
   # updatePickerInput(session = session,
                    #  inputId = "sddatausage_plot_prscope",
                     # choices = choices_prjscopes(), selected = choices_prjscopes()))
 # })
  
  choices_prjscopes_plot <- reactive({
    cscprjscopes_plotly <- sddekstop_projects_flavnames()$cscprjscope %>% unique()
    cscprjscopes_plotly
  })
  
  observe({
    updateCheckboxGroupButtons(session = session,
                               inputId = "sddatausage_plot_prscope",
                               choices = choices_prjscopes_plot(), selected = choices_prjscopes_plot(),
                               status = "success",
                               checkIcon = list(
                                 yes = icon("ok",
                                            lib = "glyphicon")))
  })
  

  choices_flavours_plot <- reactive({
    flavours_vm_plot <- sddekstop_projects_flavnames()$flavor %>% unique()
    flavours_vm_plot
  })
  
  observe({
    updatePickerInput(session = session,
                      inputId = "sddatausage_plot_flavourname",
                      choices = choices_flavours_plot(), selected = choices_flavours_plot())
    
  })
  
  
  #sddekstop_users$id_project <- as.character(sddekstop_users$id_project)
  
  # Select year on projectpage
  output$year_selector <- renderUI({
    
    pickerInput( # shinyWidgets
      inputId = "year_selector",
      label = h4("Select year(s)"),
      choices = as.vector(sort(unique(sddekstop_projects()$year))),
      selected = 2022,
      multiple = FALSE,
      options = list(
        `actions-box` = TRUE,
        `live-search` = TRUE,
        title = "Select years to include")
    )
    
  })
  
  output$sddesktop_usage_table = DT::renderDataTable({
    
    
    sddesktop_usage <- sddekstop_projects_flavnames() %>% #based on flavour data only if there is picker 
      filter(cscprjstate %in% input$sddatausage_select_status) %>%
      filter(cscprjscope %in% input$sddatausage_select_scope) %>%
      filter(year %in% input$year_selector) %>%
      filter(flavor %in% input$fl_selector) %>%
      distinct_at(vars(-flavor))  %>%
      select(-cscprjstate, -cscprjscope) 
    
    
    if(input$sddatausage_individualusers == "Yes") {
      
      sddesktop_usage  <- sddesktop_usage %>%
        right_join(sddekstop_users(), by = c("id_project" = "id_project", "year" = "year", "cscprjnum" = "cscprjnum"))
      
    }
    
    DT::datatable(sddesktop_usage %>%
                    select(-id_project) %>%
                    arrange(cscprjnum),
                  extensions = 'Buttons',
                  rownames = TRUE,
                  filter = 'top',
                  selection = 'none') 
    
  })
  
  # Datausage visualization tab, data usage in different organizations
  output$sddatausage_plot_org <- renderPlotly({
    
    dataplot <- sddekstop_projects() %>% group_by(cscorgnameen) %>% 
      filter(cscprjscope %in% input$sddatausage_plot_prscope) %>%
      filter(flavor %in% input$sddatausage_plot_flavourname) %>%
      filter(year %in% input$year_selector) %>%
      distinct_at(vars(-flavor))  %>%
      summarise(vm_bus = sum(vm_bus, na.rm = T)) %>%
      arrange(desc(vm_bus)) %>%
      head(10)
    
    plot_ly(dataplot,
            hoverinfo = 'text',
            text = ~round(vm_bus, digits = 2),
            textposition = "auto",
            colors = dataplot$cscorgnameen,
            textfont = list(color = 'rgb(0,0,0)')
    ) %>%
      add_bars(orientation = 'v',
               x = ~reorder(cscorgnameen,vm_bus),
               y = ~vm_bus,
               name = ~vm_bus) %>%
      config(displaylogo = FALSE) %>%
      layout(autosize = T,
             margin = list(l = 60, r = 0, t = 60, b = 100),
             showlegend = F,
             #annotations = annotations,
             title = "SD Desktop virtual machine usage in organisations",
             yaxis = list(title = ''),
             xaxis = list(title = '', tickangle = 45),
             barmode = "stack")
    
    
    
  })
  
  # Datausage visualization tab, data usage  for different projects
  
  output$sddatausage_plot_proj <- renderPlotly({
    
    dataplot2 <- sddekstop_projects() %>% group_by(cscprjnum) %>% 
      filter(cscprjscope %in% input$sddatausage_plot_prscope) %>%
      filter(flavor %in% input$sddatausage_plot_flavourname) %>%
      filter(year %in% input$year_selector) %>%
      distinct_at(vars(-flavor)) %>%
      summarise(vm_bus = sum(vm_bus, na.rm = T)) %>%
      arrange(desc(vm_bus)) %>%
      head(10)
    
    plot_ly(dataplot2,
            hoverinfo = 'text',
            text = ~round(vm_bus, digits = 2),
            textposition = "auto",
            colors = dataplot2$cscprjnum,
            textfont = list(color = 'rgb(0,0,0)')
    ) %>%
      add_bars(orientation = 'v',
               x = ~reorder(cscprjnum,vm_bus),
               y = ~vm_bus,
               name = ~vm_bus) %>%
      config(displaylogo = FALSE) %>%
      layout(autosize = T,
             margin = list(l = 60, r = 0, t = 60, b = 100),
             showlegend = F,
             #annotations = annotations,
             title = "SD Desktop virtual machine usage in projects",
             yaxis = list(title = ''),
             xaxis = list(title = '', tickangle = 45),
             barmode = "stack")
    
  })
  
 
  # data visualisation for users per organisation
  output$sd_users_plot <- renderPlotly({
    
    sddesktop_usage <- sddekstop_projects_flavnames() %>% #based on flavour data only if there is picker 
      filter(cscprjstate %in% input$sddatausage_select_status) %>%
      filter(cscprjscope %in% input$sddatausage_select_scope) %>%
      filter(year %in% input$year_selector) %>%
      filter(flavor%in% input$fl_selector) %>%
      distinct_at(vars(-flavor))  %>%
      select(-cscprjstate, -cscprjscope) 
    
    comb_users <- sddekstop_users() %>%
      left_join(sddesktop_usage, by = c("id_project" = "id_project", "year" = "year", "cscprjnum" = "cscprjnum")) 
    
    dataplot_users <- comb_users %>%
      group_by(cscorgnameen) %>% 
      summarise(n_users = n_distinct(id_user)) %>%
      arrange(desc(n_users)) %>%
      head(10)
    
    plot_ly(dataplot_users,
            hoverinfo = 'text',
            text = ~n_users,
            textposition = "auto",
            colors = dataplot_users$cscorgnameen,
            textfont = list(color = 'rgb(0,0,0)')
    ) %>%
      add_bars(orientation = 'v',
               x = ~reorder(cscorgnameen, n_users),
               y = ~n_users,
               name = ~n_users) %>%
      config(displaylogo = FALSE) %>%
      layout(autosize = T,
             margin = list(l = 60, r = 0, t = 60, b = 100),
             showlegend = F,
             title = "SD Desktop users in organisations",
             yaxis = list(title = ''),
             xaxis = list(title = '', tickangle = 45),
             barmode = "stack")
    
  })

Welcome,
experience tells us that posts requesting help which are both reproducible (can be simply run on a fellow forum users computer), and minimal (not containing too many excess, extraneous, irrelevant additional details) get more engagement.

Here is a guide towards that LINK

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.