只是我还是一个错误,如果我有一个因子列并且我添加了带有 DT 的过滤器,下拉列表在闪亮的仪表板中被截断。
我以 mtcars 为例,我将 cyl 作为一个因素。(数字滑块过滤器工作正常,但因子过滤器不行)。这是代码和屏幕截图。
## app.R ##
library(shinydashboard)
library(dplyr)
mtcars$cyl <- as.factor(mtcars$cyl)
ui <- dashboardPage(
dashboardHeader(title = "Simple Dashboard"),
## Sidebar content
dashboardSidebar(sidebarMenu(
menuItem(
"Dashboard", tabName = "dashboard", icon = icon("dashboard")
),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)),
## Body content
dashboardBody(tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)),
# Second tab content
tabItem(tabName = "widgets",
fluidRow(DT::dataTableOutput('items_dt')))
))
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata\[seq_len(input$slider)\]
hist(data)
})
output$items_dt = DT::renderDataTable(
mtcars,
filter = 'bottom',
options = list(scrollX = TRUE)
)
}
shinyApp(ui, server)