hi, you might have a look at that https://rstudio.github.io/DT/
here is a piece of code (sorry if it's messy...), there is probably other way to achieve that!
iris_df <- iris %>%
mutate(
diff = cut(Sepal.Width - Petal.Length, breaks = c(-Inf, 0, +Inf))
)
datatable(iris_df) %>%
formatStyle('diff',
backgroundColor = styleEqual(levels(iris_df$diff), c('green', 'red'))
)