14

Below is the code I have written. I am not able to use formattable in my shiny. formattable helps in formatting the tables and improves the visualization also.

library("shinydashboard")
library("shiny")
library("formattable")

body <- dashboardBody(
  fluidRow(
    column(width = 12,
           box(tableOutput(formattable(test.table, list())))
           )
    )
  )

ui <- dashboardPage(
  dashboardHeader(title = "Column layout"),
  dashboardSidebar(),
  body
)

server <- function(input, output) {

  test.table <- data.frame(lapply(1:8, function(x) {1:10}))

    output$table <- renderTable({test.table})
}
shinyApp(ui = ui, server = server)
Kun Ren
  • 4,715
  • 3
  • 35
  • 50
Akshit
  • 349
  • 1
  • 3
  • 10
  • put the code used to make the table in the render function, `output$table <- renderTable({ formattable(test.table) })`, and just the name of the output in the output function, `fluidRow(column(width = 12, tableOutput('table')))`. – Rorschach Oct 27 '15 at 08:43
  • Not working. It's throwing output but not same as formattable(test.table). Format is not same – Akshit Oct 27 '15 at 08:55
  • 1
    well there is a `renderFormattable` and `formattableOutput`, they probably do what you want, and if not all you need to do is change the css associated with the table container – Rorschach Oct 27 '15 at 09:08

1 Answers1

31

you have to use renderFormattable, formattableOutput and formattable, all three for it to work

library("shinydashboard")
library("shiny")
library("formattable")

body <- dashboardBody(
 fluidRow(
   column(width = 12,
        box(formattableOutput("table"))
   )
 )
)

ui <- dashboardPage(
    dashboardHeader(title = "Column layout"),
    dashboardSidebar(),
    body
 )

 server <- function(input, output) {

    test.table <- data.frame(lapply(1:8, function(x) {1:10}))

    output$table <- renderFormattable({formattable(test.table, list())})
}
shinyApp(ui = ui, server = server)
MySchizoBuddy
  • 1,138
  • 13
  • 20