We can style one column based on the values from another using the following code from this link
https://rstudio.github.io/DT/010-style.html
# style V1 base on values of V6
datatable(df) %>% formatStyle(
'V1', 'V6',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)
How can we adapt the code to display
V1 based V6 values
V2 based on V5 values
V3 based on V4 values
all simultaneously
Also, if possible, before display, I would like to delete V4,V5 and V6 columns.
So, there will be V1:V3 columns with color coding from V4:V6
I tried
# style V1:V3 base on values of V4:V6
datatable(df) %>% formatStyle(
'V1', 'V6','V2', 'V5','V3', 'V4',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)