[英]R-shiny app- DT package column information
I am trying to create an R shiny app using the DT package. I would like to add information about the column header when the user toggles over it.我正在尝试使用 DT package 创建一个 R shiny 应用程序。我想在用户切换时添加有关列 header 的信息。 Example: In "mtcars" data set, if a user toggles over 'mpg'column, they should be able to see a one-line definition for it.
示例:在“mtcars”数据集中,如果用户切换“mpg”列,他们应该能够看到它的单行定义。 I searched for solutions online but could not find any.
我在网上搜索了解决方案,但找不到任何解决方案。 I would genuinely be grateful to you for helping me with this.
我真的很感谢你帮我解决这个问题。 Also, I would appreciate it if anyone could send me links to some beautiful DT related apps.
另外,如果有人能给我发送一些与 DT 相关的精美应用程序的链接,我将不胜感激。
You can do:你可以做:
library(DT)
headerCallback <- c(
"function(thead, data, start, end, display){",
" var tooltips = ['tooltip1','tooltip2','tooltip3','tooltip4','tooltip5'];",
" for(var i=0; i<5; i++){",
" $('th:eq('+i+')',thead).attr('title', tooltips[i]);",
" }",
"}"
)
datatable(iris, rownames = FALSE,
options = list(
headerCallback = JS(headerCallback)
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.