Ниже приведен пример с USArrests наборов данных:
sketch <- htmltools::withTags(table(
tableHeader(c('State', names(USArrests))),
tableFooter(rep('', 5))
))
#here is a copy of the javascript you had link
opts <- list(
footerCallback = JS("function(row, data, start, end, display) {",
"var api = this.api(), data;",
"var intVal = function (i) {",
"return typeof i === 'string' ?",
"i.replace(/[\\$,]/g, '')*1 :typeof i === 'number' ?",
"i : 0;};",
"total = api",
".column(3)",
".data()",
".reduce(function (a, b) {",
" return intVal(a) + intVal(b);",
" }, 0);",
"$(api.column(3).footer()).html('('+ total +' total)');",
"}"))
datatable(USArrests, container = sketch, options = opts)