【问题标题】:Muliple table captions in DT in RR中DT中的多个表格标题
【发布时间】:2019-10-20 16:47:49
【问题描述】:

我正在关注这里的示例:https://rstudio.github.io/DT/

我可以在表格上方添加标题:

library(DT)

datatable(
  head(iris),
  caption = 'Table 1: This is a simple caption for the table.'
)

表格下方的标题是:

library(DT)

datatable(
  head(iris),
  caption = htmltools::tags$caption(
    style = 'caption-side: bottom; text-align: center;',
    'Table 2: ', htmltools::em('This is a simple caption for the table.')
  )
)

我怎么能同时有两个字幕(上方和下方)?

干杯, 凯特

【问题讨论】:

    标签: r shiny datatables r-markdown dt


    【解决方案1】:

    你可以这样做:

    library(DT)
    
    js <- c(
      "function(settings){",
      "  var datatable = settings.oInstance.api();",
      "  var table = datatable.table().node();",
      "  var caption = 'ANOTHER CAPTION'",
      "  $(table).append('<caption style=\"caption-side: bottom\">' + caption + '</caption>');",
      "}"
    )
    
    datatable(
      head(iris),
      options = list(
        drawCallback = JS(js)
      ),
      caption = 'Table 1: This is a simple caption for the table.'
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-02
      • 1970-01-01
      • 2021-09-07
      • 2019-02-09
      • 1970-01-01
      • 1970-01-01
      • 2015-12-14
      相关资源
      最近更新 更多