[英]how to change background and text color of DT Datable header in R Shiny
[英]Put shiny widget as column header in dt::datable
有沒有辦法在此處添加 shiny 小部件作為selectInput()
作為數據表列 header,以使用戶將Species
從那里查看他想要的相關數據。
## app.R ##
library(shiny)
library(shinydashboard)
library(DT)
Species<-unique(iris$Species)
value<-c(5,6,7)
df<-data.frame(Species,value)
ui <- dashboardPage(
dashboardHeader(title = "My Chart"),
dashboardSidebar(
),
dashboardBody(
selectInput("sel","Species",choices=unique(iris$Species),selected = unique(iris$Species)[1],multiple = F),
dataTableOutput("table")
)
)
server <- function(input, output) {
#Plot for Trace Explorer
output$table<-renderDataTable(
datatable(df)
)
}
shinyApp(ui, server)
該功能內置在數據表 package 中。 您可以使用filter
參數。
output$table<-renderDataTable(
datatable(df,
filter = "top")
)
這將為因子變量添加 select 下拉列表,並為字符變量添加常規輸入框。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.