1

I am developing a shiny application wherein for the first time i am trying to use navbarPage. Earlier I used to code with sidebar and mainpanel method but that looks elementary level. This navbarpage gives a website Look to the Application.

I am unable to control the inputs in a appropriate tab as required. The scenario is as such that one can see in Image Select io is getting displayed in every tab where i required input. Select io should be displayed only in the Anomaly tab.

Shiny navbarPage Interface

    shinyUI(fluidPage(theme = shinytheme("spacelab"),
                  tags$head(includeScript("googleanalytics.js")),

          navbarPage(p(strong(code("IOT Analytics"))),


                   tabPanel("Introduction",tags$br(),

                            p(strong(code("Brief About the Approach")))

                   ) ,
                   # First Navigation-Tab Panel 

                   tabPanel("Data-Glimpse",tags$br(),
                            # Application title
                            #titlePanel("Classification of Heart Disease w/KNN"),


                            p(strong(code("Data Overview"))),
                                DT::dataTableOutput('Raw_Data')

                            ) ,

                   # Second navigation-Tab Panel

                   tabPanel("Data-Summary",tags$br(),

                            p(strong(code("Dimension"))),
                            verbatimTextOutput("dim"),
                            p(strong(code("Summary"))),
                            verbatimTextOutput("sum")
                            ),
                   # Third navigation-Tab Panel (select io should only displayed in Anomaly Detection Tab)
                   navbarMenu("Anomaly Detection",


                                 column(4,uiOutput("selt1"))
                               ,

                              tabPanel("Visualisation",
                                       tags$br(),
                                       plotlyOutput("plot1", height = "600px")

                                       ),

                              tabPanel("Anomaly-01",
                                       # fluidRow(
                                       #   column(4,uiOutput("selt1"))
                                       # ),
                                       tags$br(),
                                       dataTableOutput("temp")
                                       ,value = "T4_2"),
                              tabPanel("Error Insight", tags$br()

                                       )




                              ),
                   tabPanel("About",tags$br()) 
  #---------------------------------------------End              

)))
James Z
  • 12,209
  • 10
  • 24
  • 44
Harvey
  • 245
  • 2
  • 9
  • Assuming `uiOutput("selt1")` contains the `selectInput`, it should be inside a `tabPanel` to show up only in a tab – greg L Oct 29 '17 at 21:17
  • @gregL , Yes your assumption is correct it is `selectinput` .i want this `uiOutput("selt1")` in all the three tabs which recites inside the `navbarMenu("Anomaly Detection",` as you can observe in this image. – Harvey Oct 30 '17 at 04:13

1 Answers1

3

try somthing like

library(shinythemes)
library(shiny)
library(plotly)

ui<- fluidPage(theme = shinytheme("spacelab"),

              navbarPage(p(strong(code("IOT Analytics"))),


                         tabPanel("Introduction",tags$br(),

                                  p(strong(code("Brief About the Approach")))

                         ) ,

                         tabPanel("Data-Glimpse",tags$br(),

                                  p(strong(code("Data Overview"))),
                                  DT::dataTableOutput('Raw_Data')

                         ) ,


                         tabPanel("Data-Summary",tags$br(),

                                  p(strong(code("Dimension"))),
                                  verbatimTextOutput("dim"),
                                  p(strong(code("Summary"))),
                                  verbatimTextOutput("sum")
                         ),
                         navbarMenu("Anomaly Detection",

                                   #add conditionalPanel here with respective tabs
                                     conditionalPanel(
                                      'input.navbar == "Visualisation"||input.navbar == "Anomaly-01"||input.navbar == "Error Insight"',
                                      selectInput("variable", "Variable:", c("a","b","c"))
                                    ),


                                    tabPanel("Visualisation",
                                             tags$br()


                                    ),

                                    tabPanel("Anomaly-01",
                                             tags$br(),
                                             dataTableOutput("temp")
                                             ),
                                    tabPanel("Error Insight", tags$br()

                                    )




                         ),
                         tabPanel("About",tags$br()), 

              #id for navbarPage           
             id="navbar" ))



server <- function(input, output){

}

shinyApp(ui, server)

Basically add a conditionalPanel and an id for your tabs in navbarPage

CER
  • 854
  • 10
  • 22
  • Thank you for solution , its working well now....Just for the curiosity if i want the same `select io` in all the tab `Data GLimpse` or `Data Summary` or `Anomaly Detection` How it would be , i guess its `id` for `navbarPage`. – Harvey Nov 01 '17 at 11:48
  • You just add the respective tab name to the conditional panel e.g. `conditionalPanel('input.navbar == "Visualisation"||input.navbar == "Anomaly-01"||input.navbar == "Error Insight"||input.navbar == "Data-Summary"',selectInput("variable", "Variable:", c("a","b","c")))` – CER Nov 01 '17 at 15:48
  • And if the first solution helped you please accept it as the answer. (little checkmark on the left of the question) – CER Nov 01 '17 at 15:51