【发布时间】:2015-02-06 06:13:49
【问题描述】:
我想知道你是否可以帮忙。我有一个简单的闪亮应用程序,它呈现一个数据表,我想根据一些标准突出显示行的颜色。
这是我可以运行的代码:
图书馆(闪亮)
runApp(list(
ui = shinyUI(fluidPage(
sidebarPanel(),
mainPanel(dataTableOutput("Table") )
)),
server = function(input, output, session) {
output$Table<- renderDataTable({
Data<-data.frame(RowNumber= c(1,2,3,4,5,6),Type= c("R","E", "R","E","R","G"), YN =c("N","N","Y","N","Y","N"),P = c(500,100,500,900,0,900))
print(Data[Data$P== 0,])
Data
})
}
))
我根本没有使用过闪亮的 CSS,但我想根据一些标准为数据表中的每一行着色。标准是:
(1) If "Type" = R AND "YN"= N AND "P" >0 then color the entire row orange
(2) If "Type" = R AND "YN"= Y AND "P" >0 then color the entire row blue
(3) If "Type" = R AND "YN"= Y AND "P" = 0 then color the entire row yellow
当然,这种着色必须与内置的排序和搜索功能等配合使用。
我已经看到了这个解决方案,但无法让它发挥作用:
How to change Datatable row background colour based on the condition in a column, Rshiny
那里的作者提到了 DataTable 的“回调”功能。你知道在这种情况下如何使用它吗?
你能帮忙吗?
【问题讨论】: