I am searching to include plotly charts in a column of a DT table in R, similar to sparkline package.
I can't get the plotly objects to render. My current trials give empty column or having the html displayed as character.
library(DT)
library(plotly)
library(htmltools)
plot_list <- lapply(1:5, function(i) {
plot_ly(y = rnorm(10), type = "scatter", mode = "lines") %>%
layout(xaxis = list(showticklabels = FALSE, ticks = ""),
margin = list(l = 1, r = 0, t = 0, b = 0))
})
plot_html <- lapply(plot_list, function(p) {
as.character(tagList(p))
})
df <- data.frame(
ID = 1:5,
Preview = I(plot_html)
)
DT::datatable(df, escape = FALSE)
I have tried to play with tagList, I and HTML functions.
Thanks for any clue!
