I'm writing a Shiny app and I would like to use formattable to color some results under conditions.
I followed the solutions provided here
and here
but none of these worked. Inexplicably, the example below does not color the results (for me at least), though the table is displayed :
library(DT)
library(shiny)
library(shinydashboard)
library(data.table)
library(formattable)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
tabsetPanel(box(formattableOutput("dat"))
)
)
)
server <- function(input, output) {
data <- head(mtcars)
output$dat <- renderFormattable({
formattable(data,
disp = formatter("span",
style = x ~ style(color = ifelse(x < 200, "green", "gray")))
)
})
}
shinyApp(ui, server)
Does somebody have a solution ?
StackOverflow link :