I use a renderFormattable
output$cn <- renderFormattable({
cn()
})
and cn is my reactive function when I put my format :
cn <- reactive({
if (input$territoire == "Département") {
if (input$donnees_ok == "Logements au") {
if (input$duree == "Trimestrielle") {
formattable(df2_dpt_lgt_aut()
, col.names = c("Departement"
,"Nb ind"
,"Nb col"
,"Nombre de logements totaux"
,"Poid logement EPCI/region"
,"Evolution T / T-1 *"
)
, align =c("l","c","c","c","c","c")
,list( "Evolution" = formatter("span"
, style = x ~ formattable::style(color = ifelse(x == "Données sur T-1 non disponibles", "grey"
,ifelse(x>0 & x!="Inf" & x != "NaN", "green"
,ifelse(x<0 & x != "NaN","red","grey"))))
,x ~ icontext(ifelse(is.numeric(x), ifelse(x < 0, "arrow-down", "arrow-up"),NA_character_), x))
,"Departement" = formatter("span"
, style = ~ formattable::style(color = "black"
,font.weight = "normal")
)))
}
#else if ###all the other condition
})