I have the shiny daashboard below in which after processing the data I create a datatable. I would like to change the color of the first column to red but it remains black. What do I miss? Is it fault related to my data frame?
## app.R ##
library(shiny)
library(shinydashboard)
library(visNetwork)
library(geomnet)
library(igraph)
library(dplyr)
library(intergraph)
library(statnet)
library(data.table)
library(DT)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
dataTableOutput("dt")
)
)
server <- function(input, output) {
nodes <- as.data.frame(lesmis[2])
colnames(nodes) <- c("id", "label")
#id has to be the same like from and to columns in edges
nodes$id <- nodes$label
#Edges
edges <- as.data.frame(lesmis[1])
colnames(edges) <- c("from", "to", "width")
#Create graph for Louvain
graph <- graph_from_data_frame(edges, directed = FALSE)
graph <- simplify(graph)
net <- asNetwork(graph) # Convert igraph network into an sna object
br<-data.frame(brokerage(net, cl=get.vertex.attribute(net, "party"))$raw.nli)
br<-setDT(data.frame(br), keep.rownames = TRUE)[]
output$dt<-renderDataTable({
colnames(br)[c(1,2,3,4,5,6,7)] <- paste0('<span style="color:',c("red","black","black","black","black","black","black"),'">',colnames(br)[c(1,2,3,4,5,6,7)],'</span>')
datatable(data.frame(br),rownames = F,escape = F)%>%
formatStyle(columns = 1, color = "black")%>%
formatStyle(columns = 2, color = "black")%>%
formatStyle(columns= 3, color = "black") %>%
formatStyle(columns = 4, color = "black") %>%
formatStyle(columns = 5, color = "black") %>%
formatStyle(columns = 6, color = "black") %>%
formatStyle(columns = 7, color = "black")
})
}
shinyApp(ui, server)