This StackOverflow discussion covers what I think is a fairly typical use case of adding tooltips to html table cells. Here is a very quick example combining formattable
with tooltipsterR
.
library(htmltools)
library(formattable)
library(tooltipsterR)
ft <- formattable(
mtcars,
formatters = structure(
lapply(
colnames(mtcars),
function(col){
formatter(
"span",
"class" = "cell-tooltip",
"title" = x~paste("tooltip for ",col,": ",x),
x~x
)
}
),
names=colnames(mtcars)
)
)
browsable(
tagList(
as.htmlwidget(ft),
tooltipster(selector=".cell-tooltip")
)
)