所以,据我所知,问题是由于您将单选按钮放置在menuItem
. 如果您只想radioButtons
在选项卡kclustering
处于活动状态时显示 ,则需要radioButtons
将conditionalPanel
. 它看起来像这样:
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Bla"),
dashboardSidebar(
sidebarMenu(
id = "tabs",
menuItem(
"K-clustering",
tabName = "kclustering",
icon = icon("cogs")),
conditionalPanel(
"input.tabs == 'kclustering'",
radioButtons("technique", "Technique Choice",
c("K-Means" = "kmeans",
"K-Medians" = "kmedians",
"K-Medoids" = "kmedoids"),
select = "kmedians")
),
menuItem("DBSCAN", tabName = "dbscan")
)
),
dashboardBody(
tabItems(
tabItem("kclustering",
fluidRow(
box(plotOutput("step1"))
))
)
))
server <- function(input, output) {
output$step1 <- renderPlot({
hist(rnorm(5000))
})
}
runApp(shinyApp(ui, server))
在这种情况下,设置sidebarMenu
对象的 id 参数以便能够制定您的条件非常重要。底线是:不要把你的radioButtons
,sliderInput
和textInput
放在menuItem
对象里面,而是放在sidebarMenu
对象本身里面。