Thanks for the time.
I am trying to get a shiny app to work correctly, and for some reason I am having difficulty on a highlighting issue when rendering a DT
data table.
For example, this works:
output$DT = DT::renderDataTable({DT = datatable(DT,options = list(searching = FALSE,paging = FALSE,lengthChange = FALSE,ordering = FALSE,rownames= FALSE)) %>%
formatStyle('TEST',backgroundColor = styleEqual(c(1,2,3,4,5), c('chartreuse', 'chartreuse4','yellow','indianred','indianred4'))) )})
However, when attempting to add this additional line, the highlighting is not appearing, yet the code runs:
%>%
formatStyle('TEST2',backgroundColor = styleEqual(c(TRUE,FALSE),c('green','red'))
I have also tried styleInterval, and am getting the same results.
Thanks.
Reproducible Code:
ui <- fluidPage(
dataTableOutput('DF')
)
server <- function(input, output, session) {
DF = as.data.frame(matrix(NA,nrow=2,ncol = 2))
DF$V1 = c(TRUE,FALSE)
DF$V2 = c(1,2)
output$DF = renderDataTable(DF)
output$DF = DT::renderDataTable({DF = datatable(DF,options = list(searching = FALSE,paging = FALSE,lengthChange = FALSE,ordering = FALSE,rownames= FALSE)) %>%
formatStyle('V2',backgroundColor = styleEqual(c(1,2,3,4,5), c('chartreuse', 'blue','yellow','indianred','indianred4'))) %>%
formatStyle('V1',backgroundColor = styleEqual(c(TRUE,FALSE),c('green','red')))})
}
shinyApp(ui = ui, server = server) # RUN THE APPLICATION