search field in shiny navbarPage

后端 未结 3 1277
我在风中等你
我在风中等你 2021-02-11 04:58

I am trying to get a global search field into my navbarPage after some tabPanel. I am not sure if it is possible, since all my tests producing the

3条回答
  •  情歌与酒
    2021-02-11 05:23

    This is one possible way, to reconstruct the menu with HTML. It does not look very clean but it does what you are looking for.

    app.R

    library(shiny)
    
        ui <- shinyUI(
                tagList(
                        bootstrapPage(
                        HTML('
                             
                             '),
                        tags$div(class="container-fluid", 
                                 tags$div(class="tab-content",
                                          HTML('
    '), sliderInput("bins1", "Number of bins:", min = 1, max = 50, value = 30), plotOutput("distPlot1"), verbatimTextOutput("searchBoxValuePlot1"), HTML('
    '), HTML('
    '), sliderInput("bins2", "Number of bins:", min = 1, max = 50, value = 30), plotOutput("distPlot2"), verbatimTextOutput("searchBoxValuePlot2"), HTML('
    ') ) ) ) )) server <- function(input, output, session) { output$distPlot1 <- renderPlot({ # generate bins based on input$bins from ui.R x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins1 + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) output$distPlot2 <- renderPlot({ # generate bins based on input$bins from ui.R x <- faithful[, 1] bins <- seq(min(x), max(x), length.out = input$bins2 + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) searchBoxValue <- reactive({ input$searchBox }) output$searchBoxValuePlot1 <- renderPrint({ paste("You entered: ", searchBoxValue(), "and you are on the first link", sep = " ") }) output$searchBoxValuePlot2 <- renderPrint({ paste("You entered: ", searchBoxValue(), "and you are on the second link", sep = " ") }) } shinyApp(ui, server)

提交回复
热议问题