R闪亮改变数据框轮廓的颜色

R Shiny change colour of data frame outline

我的服务器文件中有一个数据框如下

output$table<-renderTable({
        P.Value<- c(lev.p,bart.p,turn.p,shap.p,jar.p,linm.p) 
        Test.Statistic<-c(lev.s,bart.s,turn.s,shap.s,jar.s,linm.s) 
        df<-data.frame(P.Value,Test.Statistic)
        rownames(df, do.NULL = TRUE, prefix = "row")
        rownames(df) <- c("Levene Test","Bartlett Test","Turning Point Test","Shapiro-Wilk Test","Jarque Bera Test","Linear Model Constant Drift Test")

        df
  })

和 ui 为

column(5,tableOutput("table")

这会产生一个 table,如下所示

不过我想把table的灰色轮廓变成另一种颜色,比如黑色。我该怎么做呢?

谢谢

下面是如何在 table 中设置边框样式的示例。请转到 Tip: Adding borders to data tables with CSS for further details. Also familiarise yourself with datatables and look into the DT package. Here I used tags to style the borders (the header in blue and the rest in black). You can google the CSS colours or examples can be found here

编辑:您也可以用像素控制边框:border-width: 5px;查看here了解更多信息

rm(list = ls())
library(shiny)

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 Table Borders",
               tabPanel("Logs",icon = icon("bell"),mainPanel(htmlOutput("logs"))),
               tags$style(type="text/css", "#logs th, td {border: medium solid #00F;text-align:center}"),
               tags$style(type="text/css", "#logs td {border: medium solid #000000;text-align:center}"))

server <- (function(input, output, session) {
  my_test_table <- reactive({as.data.frame(test_table)})
  output$logs <- renderTable({my_test_table()},include.rownames=FALSE)
})

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