Это то, что вы хотите?
library(DT)
changeCellsColor <- function(rows, cols){
stopifnot(length(rows) == length(cols))
c(
"function(row, data, num, index){",
sprintf(" var rows = [%s];", paste0(rows-1, collapse = ",")),
sprintf(" var cols = [%s];", paste0(cols, collapse = ",")),
" for(var i = 0; i < rows.length; ++i){",
" if(index == rows[i]){",
" $('td:eq(' + cols[i] + ')', row)",
" .css({'background-color': 'orange'});",
" }",
" }",
"}"
)
}
datatable(iris,
options = list(
dom = "t",
rowCallback = JS(changeCellsColor(c(1,3), c(2,1)))
)
)