How to give color to a given interval of rows of a DT table?

Viewed 1750

I am using the DT library to visualize tables, but let's say I want to give a color to some rows like for example RED from row 1 to row 4:

enter image description here

Also it would be really nice to change the color of the text if it's possible. After hours of searching I found this function from library DT:

datatable(df, rownames = FALSE) %>%
  formatStyle(columns = "inputval", 
              background = styleInterval(c(0.7, 0.8, 0.9)-1e-6, c("white", "lightblue", "magenta", "white"))) 

But I need to give color to all columns not just a selected column like inputval in the code, can I give to columns value something like names(df) so it can give color to all columns? And styleInterval selects the values in table not the interval of rows, how can I do that so I can select the rows and give them a color?

1 Answers
Related