R 闪亮仪表板中DT::datatable中的因子下拉过滤器不工作
如果我有一个factor列,并且添加了带有DT的filter,那么这个下拉列表就会在闪亮的仪表板中被截断,这只是我的问题还是一个bug 我以mtcars为例,将cyl作为一个因素。(数字滑块过滤器工作正常,但因子过滤器工作不正常)。这是代码和屏幕截图R 闪亮仪表板中DT::datatable中的因子下拉过滤器不工作,r,shiny,shiny-server,shinydashboard,dt,R,Shiny,Shiny Server,Shinydashboard,Dt,如果我有一个factor列,并且添加了带有DT的filter,那么这个下拉列表就会在闪亮的仪表板中被截断,这只是我的问题还是一个bug 我以mtcars为例,将cyl作为一个因素。(数字滑块过滤器工作正常,但因子过滤器工作不正常)。这是代码和屏幕截图 ## app.R ## library(shinydashboard) library(dplyr) mtcars$cyl <- as.factor(mtcars$cyl) ui <- dashboardPage( dashb
## 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)
##app.R##
图书馆(shinydashboard)
图书馆(dplyr)
mtcars$cyl我在下拉列表方面运气更好,因为我没有使用scrollX或scrollY,而是在顶部放置了过滤器
B^(这似乎是带有DT的闪亮仪表板中的一个错误。报告了我通过将仪表板中数据框的列类型更改为factor:df[,'X1']解决了这个问题。如果将过滤器放在顶部,则所有数据框都会被截断,甚至数字滑块:(