小编MPa*_*dar的帖子

如何将总计添加到 DT::datatable?

我正在尝试将总计添加到数据表页脚。使用来自不同来源的代码,我使用 Shiny 编写了以下应用程序。问题是,当我运行它时,会出现以下消息:

“加工 ...”

并永远留在那里。

我的猜测是 JS() 代码,但无法调试。

library(shiny)
library(DT)
library(htmltools)

ui <- fluidPage(


  fluidRow(
    column(9, DT::dataTableOutput('withtotal'))
  )

)
server <- function(input, output, session) {

  # server-side processing
  mtcars2 = mtcars[, 1:8]
  #sketch <- htmltools::withTags(table(tableHeader(mtcars2), tableFooter(mtcars2)))

  sketch = htmltools::withTags(table(tableFooter(c("",0,0,0,0,0,0,0))))

 opts <- list( footerCallback = JS("function ( row, data, start, end, display ) {",
     "var api = this.api();",
     "var intVal = function ( i ) {",
      "return typeof i === 'string' ?",
       "i.replace(/[\\$,]/g, '')*1 :",
         "typeof i === 'number' ?", …
Run Code Online (Sandbox Code Playgroud)

javascript r shiny dt

6
推荐指数
2
解决办法
3436
查看次数

标签 统计

dt ×1

javascript ×1

r ×1

shiny ×1