【发布时间】:2020-08-13 22:44:36
【问题描述】:
我想知道是否可以不根据单元格的值而是根据单元格值与用户提供的另一个参考编号之间的差异来更改 DT 表格单元格背景的颜色。因此,如果差异为
以下是使用单元格值作为标准的经典示例,这不是我需要的。 谢谢!
library(shiny)
library(DT)
#>
#> Attaching package: 'DT'
#> The following objects are masked from 'package:shiny':
#>
#> dataTableOutput, renderDataTable
ui <- shinyUI(fluidPage(
mainPanel(
DT::dataTableOutput("table")
)
))
server <- shinyServer(function(input, output) {
dfr <- data.frame("x"=c(1, 2, 3),
"y"=c(10, 12, 14))
Reference <- 13
output$table <- DT::renderDataTable(datatable(dfr) %>% formatStyle('y', backgroundColor = styleEqual(c(10, 12, 14), c('gray', 'yellow', 'red'))))
})
shinyApp(ui = ui, server = server)
【问题讨论】: