Possible to combine DT, formattable and shiny?

Viewed 3802

Formattable have some easy options to format table, for example:

library(shiny)
library(DT)
library(formattable)

  df <- formattable(iris, lapply(1:4, function(col){

    area(col = col) ~ color_tile("red", "green")

This can later be coverted to a DT datatable

df <- as.datatable(df)

For me it works perfefect to view in the Viewer in RStudion. However, I would like to deploy it as a Shiny app somehow. Complete code:

library(DT)
library(shiny)

ui <- fluidPage(
  DT::dataTableOutput("table1"))


server <- function(input, output){

  df <- formattable(iris, lapply(1:4, function(col){

    area(col = col) ~ color_tile("red", "green")

  }))

  df <- as.datatable(df)

  output$table1 <- DT::renderDataTable(DT::datatable(df))

}

shinyApp(ui, server)

This does not work, is there any work around? I like the conditional formatting from formattable, but would also like to use some options that DT offers as for example filtering, searching, colvis etc.

To just deploy it as a formattable there is a thread:

How to use R package "formattable" in shiny dashboard?

1 Answers
Related