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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -