我正在使用navbarPage使用sidebarPanel.
我想"声明"只有一个小部件(本例中为radioButtons),然后将每个标签链接到"main"sidebarPanel.如您所见,tab2对相对radioButtons没有反应.我的项目结构更复杂,需要为某些选项卡设置相同的sidebarPanel,并为某些其他选项卡设置特定的sidebarPanel.这是我正在使用的代码:
library(shiny)
server=function(input, output) {
output$plot1 = renderPlot({plot(runif(input$rb))})
output$plot2 = renderPlot({plot(runif(input$rb))})
}
ui = shinyUI(navbarPage("Test multi page",
tabPanel("tab1",
sidebarLayout(
sidebarPanel(
radioButtons("rb","Nr of obs:",choices = c("50 obs"=50,"300 obs"=300))
),
mainPanel(plotOutput("plot1"))
)
),
tabPanel("tab2",
sidebarLayout(
sidebarPanel(
radioButtons("rb","Nr of obs:",choices = c("50 obs"=50,"300 obs"=300))
),
mainPanel(plotOutput("plot2"))
)
)
))
shinyApp(ui = ui, server = server)
runApp("app")
Run Code Online (Sandbox Code Playgroud)