(可复制代码):
library(shiny)
ui <- fluidPage(
sidebarPanel(
tabsetPanel(
tabPanel("tab1", checkboxInput("opt1", "opt1 for 1 tab")),
tabPanel("tab2", checkboxInput("opt2", "opt2 for 2 tab"))
)
),
mainPanel(
navbarPage("choose page",
navbarMenu("page1",
tabPanel("panel1",
mainPanel(plotOutput("plot1"))
),
tabPanel("panel2", plotOutput("plot2"))
),
navbarMenu("page2", tabPanel("panel3", plotOutput("plot3")), tabPanel("panel4", plotOutput("plot4")))
)
)
)
server <- function(input, output){
}
shinyApp(ui, server)
我想在sidebarPanel中添加:
page1
和panel1
page1
{常见于panel1
和panel2
有可能闪亮吗?
答案 0 :(得分:1)
是的,将id
添加到navbarPage
并使用conditionalPanel
:
ui <- fluidPage(
sidebarPanel(
conditionalPanel(
'input.navbar == "panel1"',
checkboxInput("checkbox1", "Hello")
),
conditionalPanel(
'input.navbar == "panel1" || input.navbar == "panel2"',
checkboxInput("checkbox1", "Goodbye")
)
),
mainPanel(
navbarPage("choose page",
navbarMenu("page1",
tabPanel("panel1",
mainPanel(plotOutput("plot1"))
),
tabPanel("panel2", plotOutput("plot2"))
),
navbarMenu("page2", tabPanel("panel3", plotOutput("plot3")), tabPanel("panel4", plotOutput("plot4"))),
id = "navbar"
)
)
)
答案 1 :(得分:-1)
为什么它不能正常工作?
library(shiny)
ui <- fluidPage(
navbarPage("Choose page: " ,
navbarMenu("Discovering the dataset",
sidebarPanel(
checkboxInput("x", "x")
),
tabPanel("volume", mainPanel(plotOutput("pp"))),
tabPanel("amount salary"),
tabPanel("map"),
tabPanel("data"),
tabPanel("animation"),
tabPanel("wordcloud")
),
navbarMenu("Options"),
navbarMenu("More information")
)
)
server <- function(input, output){
output$pp <- reactivePlot({plot(1,1)})
}
shinyApp(ui, server)
这里我想要所有barpage Discovering the dataset