Помогает?
library(DT)
changeCellColor <- function(i, j, color){
color <- sprintf("'%s'", color)
c(
"function(row, data, num, index){",
sprintf(" var i = [%s], j = [%s], color = [%s];",
toString(i-1), toString(j), toString(color)),
" var n = i.length;",
" for(let k=0; k < n; k++){",
" if(index == i[k]){",
" $('td:eq(' + j[k] + ')', row)",
" .css({'background-color': color[k]});",
" }",
" }",
"}"
)
}
datatable(iris[1:5,],
options = list(
dom = "t",
rowCallback = JS(changeCellColor(c(1,2), c(2,1), c("blue","red")))
)
)