Shiny 在列表中仅高亮显示表中的一列

Shiny 在列表中仅高亮显示表中的一列,shiny,Shiny,我目前正在设计一个输出表格的闪亮应用程序。我想突出显示特定列中的单元格(例如,使单元格变为蓝色)。我尝试过使用shinyBS包中的HighlightRows函数,但似乎不起作用 下面是我的服务器脚本的一部分组成了表: output$text1 <- renderTable({ tab1 <- as.data.frame(matrix(c(rrround(input$patha,3),PowerF()$tta,input$nxn,rrround(currentInput()$pat

我目前正在设计一个输出表格的闪亮应用程序。我想突出显示特定列中的单元格(例如,使单元格变为蓝色)。我尝试过使用shinyBS包中的HighlightRows函数,但似乎不起作用

下面是我的服务器脚本的一部分组成了表:

output$text1 <- renderTable({
  tab1 <- as.data.frame(matrix(c(rrround(input$patha,3),PowerF()$tta,input$nxn,rrround(currentInput()$patha,3),rrround(rxyval()$rxy,3),rrround(rxyval()$rxy_p,3),rround(PowerF()$tra,3),
                                  rrround(input$pathp,3),PowerF()$ttp,input$nxn,rrround(currentInput()$pathp,3),rrround(rxyval()$rxyp,3),rrround(rxyval()$rxyp_p,3),rround(PowerF()$trp,3))
                                ,ncol=7, byrow=TRUE))

   rownames(tab1) <- c('Actor', 'Partner')
   colnames(tab1) <- c('Size', 'Power', 'N','Beta','r','partial r','ncp')
   tab1.align = "r"

   highlightRows(session, id='tab1', class = "info", column="Power", regex = ".")
   print(tab1, type="html")

output$text1您可以使用
tags$script
修改数据表。下面是突出显示示例数据表的3列(1)、(5)和(9)的示例。我有一个小问题与类似的问题,你可以查看

rm(list=ls())
图书馆(闪亮)
选项(位数.秒=3)
测试表
rm(list = ls())
library(shiny)
options(digits.secs=3) 

test_table <- cbind(rep(as.character(Sys.time()),10),rep('a',10),rep('b',10),rep('b',10),rep('c',10),rep('c',10),rep('d',10),rep('d',10),rep('e',10),rep('e',10))
colnames(test_table) <- c("Time","Test","T3","T4","T5","T6","T7","T8","T9","T10")

ui =navbarPage(inverse=TRUE,title = "Coloring datatables",
               tabPanel("Logs",icon = icon("bell"),
                        mainPanel(htmlOutput("logs"))),
               tabPanel("Extra 2",icon = icon("bell")),
               tabPanel("Extra 3",icon = icon("bell")),
               tags$style(type="text/css", "#logs td:nth-child(1) {text-align:center;background-color:red;color: white;text-align:center}"),
               tags$style(type="text/css", "#logs td:nth-child(5) {text-align:center;background-color:blue;color: white;text-align:center}"),
               tags$style(type="text/css", "#logs td:nth-child(9) {text-align:center;background-color:green;color: white;text-align:center}")
)
server <- (function(input, output, session) {

  my_test_table <- reactive({
    other_data <- rbind(c(as.character(Sys.time()),(sample(c("Pass","Aggr","Bad"))[1]),round(c(rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1)),2)),  
                        (c(as.character(Sys.time()),(sample(c("Pass","Aggr","Bad"))[1]),round(c(rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1),rnorm(1)),2))))
    test_table <<- rbind(apply(other_data, 2, rev),test_table)
    as.data.frame(test_table) 
  })
  output$logs <- renderTable({my_test_table()},include.rownames=FALSE)

})

runApp(list(ui = ui, server = server))