I'm having the following problem. I want to conditionally format my columns so that values in column 2 that are non-positive are coloured red. I also want this condition to hold afte a cell has been edited. For example:
library(DT)
df <- data.frame(
col1 = 1:5,
col2 = c(-1,-1,0,1,1)
)
datatable(df,editable = T)%>%
formatStyle(
2,
color = styleInterval(cuts = 0,values = c("red","black"))
)
It works when it's displayed in the viewer section of the RStudio IDE. As I edit cell values, the colour is also updated to reflect the new value.
However, when I run it in R Shiny:
ui <- fluidPage(
dataTableOutput("test")
)
server <- function(input,output,sesion){
output$test <- DT::renderDataTable({
df <- data.frame(
col1 = 1:5,
col2 = c(-1,-1,0,1,1)
)
datatable(df,editable = T)%>%
formatStyle(
2,
color = styleInterval(cuts = 0,values = c("red","black"))
)
})
}
shinyApp(ui,server)
the callback becomes completely unresponsive. The cells coloured red at initialisation will remain red no matter how I try to edit the cell value. Can somebody please shed light as to how this phenomenon happens and how I can fix this?