【发布时间】:2018-03-04 01:28:33
【问题描述】:
我有一个包含正值和负值的矩阵 M。我正在尝试使用 DT 包在闪亮的应用程序中显示为表格。我想用不同的颜色显示矩阵。红色的正数和负数(例如)。
到目前为止,我只能以一对一的方式添加颜色。但我想以这种方式添加颜色:if matrix_values > 0 "color1", if matrix_values
M <- matrix(c(-3:2), 3) # The matrix is more complex and it's created in a
reactive environment. Here is only an example
M_out <- reactive({
DT::datatable(M()) %>%
formatStyle(
columns = c(1:7),
backgroundColor = styleEqual(c( 0, 1), c("green", "red")
))
})
output$X_table_2 <- DT::renderDataTable(M_1X2())
谢谢!!
【问题讨论】: