Jordan
Jordan

Reputation: 465

Shiny Display Matrix as Table from UI

I would like to display a matrix as a table without having to make a server call. I suspect I need something like the following

ui.r

x <- diag(4)

h4(x), ## fails
h4(xtable(x)), ## fails

Upvotes: 1

Views: 258

Answers (1)

Florian
Florian

Reputation: 25425

I am not sure if that is easily possible. As far as I know, you would have to create the right HTML for the table to display, for example using the htmlTable package.

An example is given below, hope this helps!

library(shiny)
library(htmlTable)

df = data.frame(a=LETTERS[1:6],b=letters[1:3])

ui <- fluidPage(
  HTML(htmlTable(table(df$a,df$b)))
)

server <- function(input,output, session)
{
}

shinyApp(ui,server)

Upvotes: 1

Related Questions