R Shiny can you have a navigation bar AND have a fluid page layout

12,300

Yes, you can.

It says in the documentation that you can turn this on with fluid = TRUE:

fluid TRUE to use a fluid layout. FALSE to use a fixed layout.

Share:
12,300
user3022875
Author by

user3022875

Updated on June 20, 2022

Comments

  • user3022875
    user3022875 almost 2 years

    I would like to create a shiny app with a navigation bar BUT ALSO be able to configure the layout on the page using fluid row() and fluid Column().

    I read the "NAV BAR PAGES" and "FLUID GRID SYSTEM" areas here http://shiny.rstudio.com/articles/layout-guide.html and under FLUID GRID SYSTEM it says "To create a layout based on the fluid system you use the fluidPage() function." so here is my example:

    server.r

    shinyUI(navbarPage("",
                       tabPanel("test",
                                #THIS IS THE SIDEBAR INPUT PANEL
                                column(2,wellPanel(
                                  selectInput("x", "x:", c(5, 10,30,60),selected = 5)
                                )),
    
                                #THIS IS THE MAIN CONTENT
                                column(10, 
                                       fluidRow( plotOutput("plot3")) #,
    
                                                  #fluidRow( 
                                                  #   column(width=5, plotOutput("plot2")),
                                                   #  column(width=5, plotOutput("plot3"))      
                                                 # )                                         
                                )#end of main body columns 
                       )#end tab panel
    
                                          ,
                                          tabPanel("summary",
                                                   verbatimTextOutput("summary")
                                          ),
                                          navbarMenu("More Info",
                                                     tabPanel("Test1",
                                                              dataTableOutput("table")
                                                     )
                                          )
    ))
    
    
    ui.r
    
    library(shinydashboard)
    library(reshape)
    library(quantmod)
    library(ggplot2)
    library(reshape2)
    library(scales)
    
    shinyServer(function(input, output, session) {
      output$plot1 <- renderPlot({
        #plot(cars, type=input$plotType)
        plot(c(1))
      })
    
      output$plot2 <- renderPlot({
        #plot(cars, type=input$plotType)
        plot(c(100))
      })
    
      output$plot3 <- renderPlot({
        #plot(cars, type=input$plotType)
        plot(c(-2001))
      })
    
    
      output$summary <- renderPrint({
        summary(cars)
      })
    
      output$table <- renderDataTable({
        cars
      }, options=list(pageLength=10))
    })#### END OF SHINY SERVER FUNCTION
    

    So the above code works and it has a navigation bar. BUT I would like to add another fluid row on the ui.r page in the "test" tab panel. You can see I commented out these lines:

                                      #fluidRow( 
                                      #   column(width=5, plotOutput("plot2")),
                                       #  column(width=5, plotOutput("plot3"))      
                                     # )    
    

    I would like to uncomment them and show a fluid row with 2 columns. BUT when I uncomment those lines the application does not return anything.

    So is it possible to have a nav bar page and do fluid layouts like this?

    Or do i need to use fluidPAge() instead of navBarPage()? BUT THEN how do you do a nav bar with fluidPage??