闪亮的 R- 为什么 formatStyle() 更改在我的输出数据 table 中不可见?

Shiny R- Why aren't formatStyle() changes visible in my output data table?

我正在尝试使用 formatStyle() 在 Shiny 中更改输出 table 的格式和样式,但更改不可见。可能出了什么问题?例如,我希望“是”加粗,但最终结果不会显示这些更改。 这是我的最终输出:

这是我的代码:

library(shiny)
library(dplyr)
library(DT)
library(readxl)
var_version_tables <- read_excel("test_2_filtros_2.xlsx")
df<-var_version_tables

ui <- fluidPage(
  selectInput("var_1", "Categories", choices = unique(df$var_1)),
  selectInput("var_2", "Tables", choices = NULL, multiple = T),
  DT::dataTableOutput("data")
)





server <- function(input, output, session) {
  categories <- reactive({
    filter(df, var_1 == input$var_1)
  })
  observeEvent(categories(), {
    choices <- unique(categories()$var_2)
    updateSelectInput(inputId = "var_2", choices = choices) 
  })
  
  
  output$data <- DT::renderDataTable({
    req(input$var_2)
    
    table<-categories() %>% 
      filter(var_2 %in% input$var_2) %>% 
      select(var_2, var_3)%>%
      mutate(result="Yes") %>%
      tidyr::pivot_wider(names_from = var_2, values_from = result, values_fill = "No")%>%
      rename(Columns=var_3)
    
    table_1<-DT::datatable(table, filter= 'top',options = list(order=list(0,'asc'), dom='t', pageLength= 100, autoWidth = TRUE),rownames = FALSE)
    table_2<-DT::formatStyle(table_1, columns = NULL, fontWeight = styleEqual(c('No', 'Yes'), c('normal', 'bold')))
    
    
    
    
    
    
    return(table_2)
    
    
    
    
    
  })
}

shinyApp(ui, server)






这是我的输入数据:

var_1 var_2 var_3
red table1 column1
red table1 column4
red table1 column3
blue table2 column1
blue table2 column2
blue table2 column3
blue table2 column4
blue table3 column3
blue table3 column10
blue table3 column15
blue table3 column4
blue table3 column5
pink table4 column1
pink table4 column2
pink table4 column11
pink table4 column10
pink table4 column5
pink table4 column6
pink table4 column7
blue table5 column1
blue table5 column2
blue table5 column3
yellow table6 column9
yellow table6 column10
pink table7 column6
pink table7 column7
pink table7 column8

非常感谢。

对于 columns in formatStyle 使用 table.

中的列名称而不是 NULL
    table_2 <-
      DT::formatStyle(table_1,
                      columns = colnames(table),
                      fontWeight = styleEqual(c('No', 'Yes'), c('normal', 'bold')))