I'm working on a shiny dashboard. There is a part where I use the package formattable (to format some columns) + DT(for display). The problem is that when I sort on the formatter columns, I get a wrong result. The sorting is not done correctly. Can you please help me? Thanks in advance here is the code
library(shiny)
library(formattable)
library(DT)
shinyApp(
ui = fluidPage(
fluidRow(
column(width = 12, DTOutput("test"))
)
),
server = function(input, output) {
output$test <- DT::renderDataTable ({
as.datatable(
formattable(
df_test,
list(
age = color_tile("white", "orange"),
test1_score = color_bar("pink"),
test2_score = formatter(
"span",
style = ~ formattable::style(
color = ifelse(`test2_score` < 10, "red",
ifelse(`test2_score` < 15, "orange", "green")
),
font.weight = "bold"
),
~ icontext(
# "plus"
ifelse(
`test2_score` < 10, "remove",
ifelse(`test2_score` < 15, "minus", "flash")
),
`test2_score`
)
)
)
)
)
})
}
)
here is the execution sorting by ascending order sorting by descending order