因为,我的原始数据集非常庞大,所以我使用 iris 数据集重新创建了我的问题。我添加了一列“new_var”,其中包含鲜花的描述。我遇到的问题是当我从下拉菜单中选择多个输入(> 3)时,侧边栏的长度没有得到调整以显示下拉菜单中的剩余值。
我曾尝试增加侧边栏的长度,但它不起作用。我尝试用流体页面包装dashboardSidebar,它也不起作用。
我真正想要的是侧边栏的长度是否可以动态调整,以便我可以滚动查看所有值或提供垂直滚动条。谢谢
library(datasets)
library(shiny)
library(shinydashboard)
library(DT)
data(iris)
x <- c("Small flowers","Flowers (or heads) borne singly on isolated stems or arising individually from leaf axils. Not part of a larger group.", "A simple, indeterminate inflorescence consisting of stalked flowers attached to a central stem and forming a more or less elongated cluster. The stalk of a flower is termed a pedicle and pedicled flowers are implied by the term raceme when used alone in the specific sense. ", "An indeterminate inflorescence consisting of stalkless flowers attached to a central stem, generally forming a highly elongated cluster. A raceme of stalkless flowers. ", "An indeterminate inflorescence forming a convex or flat-topped cluster, essentially a contracted raceme. Typically flowers arise from a central axis on stalks (pedicles) of different lengths that bring them all to near the same height. The term is also applied to racemes of similar shape with branching pedicles. The outermost flowers generally open first. ")
iris$new_var <- rep(x, each = 30)
ui <-
dashboardPage(
dashboardHeader(title = strong("DATA LOADER"),titleWidth = 240),
dashboardSidebar(
sidebarMenu(
selectizeInput("newvar", "Choose type of flower:", choices = sort(unique(iris$new_var)), multiple = TRUE)
)
),
dashboardBody(
fluidRow(
dataTableOutput("df"),
br()
)))
server <- function(input, output){
output$df <- renderDataTable(reactive({
iris[iris$new_var %in% input$newvar, ]
})())
}
shinyApp(ui, server)