代码之家  ›  专栏  ›  技术社区  ›  Johnny

是否可以在R的navlistPanel中包含selectInput元素?

  •  1
  • Johnny  · 技术社区  · 7 年前

    在我当前的应用程序中,我使用 navlistPanel 类似于下面的一个,我想知道是否可以添加一个 selectInput 是否将UI元素添加到导航列表?

    ui.R

    fluidPage(
    
     titlePanel("Application Title"),
    
     navlistPanel(
       "Header",
       tabPanel("First"),
       tabPanel("Second"),
       tabPanel("Third")
       # selectInput(inputId, label, choices, selected = NULL) <- I've tried this but it doesn't work
     )
    )
    

    欢迎任何解决方案/解决方法。

    sidebarLayout + sidebarPanel 会在 模仿动物的行为 但没能实现。

    2 回复  |  直到 7 年前
        1
  •  1
  •   Kevin    7 年前

    如果你可以使用 shinydashboard ,相当简单。

    library(shiny)
    library(shinydashboard)
    
    rm(list=ls)
    
    ######/ UI Side/######
    
    header <- dashboardHeader(title = "Test")
    sidebar <- dashboardSidebar(
      sidebarMenu(
        menuItem("First Tab",tabName = "FTab", icon = icon("globe")),
        menuItem("Second Tab",tabName = "STab", icon = icon("star"))
      ),
      selectInput("navSel", "Selection:", c("b","c"))
    )
    body <- dashboardBody()
    
    ui <- dashboardPage(header, sidebar, body)
    
    
    ######/ SERVER Side/######
    
    server <- function(input, output, session) {
    
    }
    
    shinyApp(ui, server)
    
        2
  •  1
  •   Tonio Liebrand    7 年前

    library(shiny)
    
    shinyApp(
      ui <- fluidPage(
        titlePanel("Application Title"),
    
        navlistPanel("Header", id = "navOut",
                     tabPanel("First", "First"),
                     tabPanel(selectInput("navSel", "Selection:", c("b", "c")), textOutput("txt"))
        )
      ),
      server <- shinyServer(function(input, output){
        output$txt <- renderText(input$navSel)
      })  
    )