R Shiny改变数据框轮廓的颜色

时间:2015-02-24 03:49:37

标签: r shiny

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

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 as

column(5,tableOutput("table")

这会产生如下表格 enter image description here

但是我想把桌子的灰色轮廓变成另一种颜色,比如黑色。我该怎么做呢?

由于

1 个答案:

答案 0 :(得分:0)

下面的

是如何在表格中设置边框样式的示例。请转至Tip: Adding borders to data tables with CSS了解详情。同时熟悉datatables并查看DT package。在这里,我使用标签来设置边框的样式(标题为蓝色,其余为黑色)。你可以谷歌CSS颜色或示例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))