0

I'd like to build a dashboard sidebar that has maybe 3 menuItems and when a menuItem is selected a checkBoxGroup will expand below and the user can select any number of options. 我该怎么办?

这是我目前拥有的代码的相关部分。

# ui.R
dashboardSidebar(
    # I need a header to say Select a Dataset
    # I want the menuItems to be selectable but 
    menuItem("Dataset 1", newTab = FALSE),
    menuItem("Dataset 2", newTab = FALSE),
    menuItem("Dataset 3", newTab = FALSE),
    # not sure where to put uiOutput so that it appears below
    #    the selected menuItem
    uiOutput("features")
)

# server.R
dataset <- reactive({
    df <- read.csv()
    return(df)
})
output$features <- renderUI({
    checkboxGroupInput("features", "Select features to plot: ",
        colnames(df))
})
4

1 回答 1

0

这是你需要做的。但是,问题是您必须单击 menuItem 的功能,单击其他地方以填充它。我现在正在尝试解决这个问题。您还必须像函数一样调用 dataset(),而不是 df。

# ui.R
header <- dashboardPage(
dashboardHeader(title ="Data Frame Features", titleWidth = 350)
)

sidebar <- dashboardSidebar(
sidebarMenu(
    # I need a header to say Select a Dataset
    # I want the menuItems to be selectable but 
    menuItem("Dataset 1", newTab = FALSE),
    menuItem("Dataset 2", newTab = FALSE),
    menuItem("Dataset 3", newTab = FALSE),
    menuItem("Dataframe Features",tabName = "features", icon = icon("th"), uiOutput("features"), selected = TRUE)
)
)

body <- dashboardBody(
tabItems(tabItem(tabName = "something")
)   

dashboardPage(
  header,
  sidebar,
  body      
) 

# server.R
dataset <- reactive({
    df <- read.csv()
    return(df)
})
output$features <- renderUI({
    checkboxGroupInput("features", "Select features to plot: ", choices= colnames(dataset()), selected = colnames(dataset()))
})
于 2016-07-09T00:34:24.093 回答