Reputation: 391
I'm wondering if it is possible to use multiple DT::formatStyle functions in R shiny.
I would like to implement colors (green and red for positive and negative numbers, respectively) as well as highlighting the last row to display column sums.
Here is the code I'm trying to work with, however I am receiving an error:
DT::formatStyle(
columns = cols,
color = DT::styleInterval(0, c('red', 'green'))
) %>%
DT::formatStyle(
'metric',
target = 'row',
backgroundColor = styleEqual('Total', 'gray'))
Upvotes: 0
Views: 2229
Reputation: 7695
Yes, there are even examles in ?formatStyle
as well as on the github pages documentation
library(dplyr)
library(DT)
datatable(mtcars) %>%
formatStyle("am", color = styleEqual(1, "red")) %>%
formatStyle("cyl", color = styleInterval(7, c("green", "blue")))
If you could provide testdata and a complete minimal working example, helping would be easier.
Upvotes: 2