Shiny App displays output in multiple tabs

This is my first Shiny App, as part of my Coursera Data Science Specialisation. I am trying to create a Tab for documentation but the output of the main tab displays in both, the MainApp tab and the Documentation.

I want no output in the "Documentation" tab

Any help? Thanks!

This is the ui.R code:

 shinyUI(
  pageWithSidebar(
    headerPanel (" Six Sigma Control Charts"),



      tabsetPanel(


        tabPanel("MainApp",
                 sidebarPanel(
                   h5 ("Control Charts are six sigma tools that track process statistics over time to detect the presence of special causes of variation. There are different types of charts according to the data type that you are analysing."),

                   selectInput("DataType", "Please select Data Type",
                               choices = c("Continuous", "Attribute")),
                   conditionalPanel(condition = "input.DataType == 'Continuous'",
                                    selectInput("Groups", "Data collected in groups?",
                                                choices = c("Yes", "No"))),
                   conditionalPanel(condition = "input.DataType == 'Attribute'",
                                    selectInput("Counting", "What are you counting?",
                                                choices = c("Defective items", "Defects per unit"))),


                   conditionalPanel(condition = "input.Groups == 'Yes' & input.DataType == 'Continuous' ",
                                    textInput ("SubgroupSize", "Enter sub group size",1 )    ) 


                 ) ),

        tabPanel("Documentation", 

                 h5 ("This Shiny App helps you to familiarise with Six Sigma Control Charts."),
                 h5 ("The different types of graphs are produced according to the type of data that you want to analyse"),
                 h5 ("Make a choice according to the data type to explore the various Six Sigma graphs")
        )





    ),



    mainPanel (

             plotOutput ("ControlChart"),
             textOutput("Explanation"),
           br(100),
           br()


    )


  )

)

Upvotes: 0

Views: 2039

Answers (1)

Birger
Birger

Reputation: 1141

It is not possible with the pageWithSidebar function. This function is deprecated anyway. Try to wrap a fluidPage in a navbarPage:

# Define UI
ui <- navbarPage("App Title",
                 tabPanel("Plot",
                          fluidPage(
                            sidebarLayout(

                              # Sidebar with a slider input
                              sidebarPanel(
                                sliderInput("obs",
                                            "Number of observations:",
                                            min = 0,
                                            max = 1000,
                                            value = 500)
                              ),

                              # Show a plot of the generated distribution
                              mainPanel(
                                plotOutput("distPlot")
                              )
                            )
                          )

                 ),
                 tabPanel("Summary",
                          tags$br("Some text"))
)

# Server logic
server <- function(input, output) {
  output$distPlot <- renderPlot({
    hist(rnorm(input$obs))
  })
}

# Complete app with UI and server components
shinyApp(ui, server)

Upvotes: 1

Related Questions