6
이 예제에서와 같이 DT 패키지의 R 버전에 요약을 추가 할 수 있습니까?데이터 테이블의 열 요약 (패키지 DT에서)
https://datatables.net/examples/advanced_init/footer_callback.html
이 예제에서와 같이 DT 패키지의 R 버전에 요약을 추가 할 수 있습니까?데이터 테이블의 열 요약 (패키지 DT에서)
https://datatables.net/examples/advanced_init/footer_callback.html
첫째 있습니다 (컨테이너 매개 변수 사용) 데이터 테이블에 바닥 글을 추가 한 다음 당신은 옵션 매개 변수 내에서 footerCallback 기능 (에 링크 된 자바 스크립트 코드를 삽입해야 데이터 테이블).
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)
: 여기
는 USArrests 데이터 세트로 한 예이다