r - Possible to combine DT, formattable and shiny? -


formattable have easy options format table, 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 coverted dt datatable

df <- as.datatable(df) 

for me works perfefect view in viewer in rstudion. however, deploy 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 not work, there work around? conditional formatting formattable, use options dt offers example filtering, searching, colvis etc.

to deploy formattable there thread:

how use r package "formattable" in shiny dashboard?

yes seems possible, mentioned here. here sample code on how achieve that:

library(shiny) library(data.table) library(formattable)  ui <- fluidpage(   selectinput("input1","species: ", choices = c("setosa", "versicolor", "virginica")),   dt::datatableoutput("table1"))  # make data.table of iris dataset.  df <- iris  server <- function(input, output){    output$table1 <- dt::renderdatatable( {      my_df <- df[df$species==input$input1,]      return(as.datatable(formattable(my_df, lapply(1:4, function(col){area(col = col) ~ color_tile("red", "green")}))))   }   )  }  shinyapp(ui, server) 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -