桌面列的R闪亮mouseover文本

Sri*_*Sri 14 r shiny dt

如何mouseover text在R闪亮数据表显示中为列名创建.我正在尝试为用户提供一些文本来理解列名称.我也检查了DT包,我找不到解决方案.我可以为列名创建标签,并在用户选中一个框时显示所有这些标签,这需要大量的空间,我不希望这样.有小费吗?

Yih*_*Xie 18

为了扩展我上面的评论,这里有一个示例,通过使用title属性显示我的意思:

library(DT)
sketch = htmltools::withTags(table(
  class = 'display',
  thead(
    tr(
      th('', title = 'Row Names'),
      th('Sepal.Length', title = 'The Sepal Length'),
      th('Sepal.Width', title = 'The Sepal Width'),
      th('Petal.Length', title = 'The Petal Length'),
      th('Petal.Width', title = 'The Petal Width'),
      th('Species', title = 'Iris Species')
    )
  )
))
datatable(iris, container = sketch)
Run Code Online (Sandbox Code Playgroud)

这是使用JavaScript(jQuery)添加title属性的另一种方法:

library(DT)
datatable(iris, callback = JS("
var tips = ['Row Names', 'The Sepal Length', 'The Sepal Width',
            'The Petal Length', 'The Petal Width'],
    header = table.columns().header();
for (var i = 0; i < tips.length; i++) {
  $(header[i]).attr('title', tips[i]);
}
"))
Run Code Online (Sandbox Code Playgroud)

  • 谢谢@Yihui ...将鼠标悬停在所有表格单元格而不是标题上的相应方法是什么?我已经尝试了很多,但到目前为止我没有管理...谢谢 (4认同)