I would like to have a popover and in the content to print a table(which in my case is named out). I have the table which looks like data.frame but when I run the command typeof(out), I get "list"
I have tried with the following code
addPopover(session=session, id="infocpbayestext", title="",
content=HTML(out), placement = "left",
trigger = "hover", options = list(html = "true"))
And with
addPopover(session=session, id="infocpbayestext", title="",
content=HTML(build_infocpbayes_table(out)), placement = "left",
trigger = "hover", options = list(html = "true"))
where build_infocpbayes_table is a function that tries to build a html table like this
"<table><tr><th>index</th><th>Date</th><th>Count</th><th>postprob</th></tr><tr> <td>..</td> <td>..</td> <td>...</td> <td>...</td> </tr></table>"
But although I build the correct string as above it does not appear in popover.
Any idea how could I do that?
Edit To give a better view of my code
shinyServer(function(input, output, session) {
output$infocpbayestext <- renderUI ({
out<-structure(list(Date = c("2003-12", "2007-09", "2007-11"), Count =c(8721L,+ 31341L, 42948L), postprob = c(1, 1, 1)), row.names = c(174L,+ 219L,221L), class = "data.frame")
addPopover(session=session, id="infocpbayestext", title="", content=HTML(build_infocpbayes_table(out)), placement = "left", trigger = "hover", options = list(html = "true"))
return(HTML('<button type="button" class="btn btn-info">i</button>'))
})
build_infocpbayes_table <- function(data){
html.table <- paste('<table style = "border: 1px solid black; padding: 1%; width: 300px;"><tr><th>index</th><th>Date</th><th>Count</th><th>postprob</th></tr><tr>',tags$td(HTML(paste0(rownames(data),collapse=""))),
tags$td(HTML(paste0(data$Date,collapse=""))),
tags$td(HTML(paste0(data$Count,collapse=""))),
tags$td(HTML(paste0(data$postprob,collapse=""))),
'</tr></table>')
return(html.table)
}})
shinyUI(uiOutput("infocpbayestext"))