我正在创建一个仪表板,用于在我的公司中调度卡车。我在Shiny中创建了一个表格,该表格显示了应该从哪个码头和特定时间派遣哪些卡车。牢房的背景取决于卡车是否准时到达。问题是,使用kableExtra中的cell_spec(background = ...)只能直接在文本后面着色,而不是填充整个单元格
我为公司名称,单元格背景,文本颜色,文本删除线创建了4个表,并使用cell_spec合并为一个表。然后将其分为两个表,分别是上午和下午
for(i in 1:nrow(df.live))
{
df.live[i, ] <- cell_spec(dt.live.output[i, ],
"html",
background = df.live.output.colors[i, ],
color = df.live.output.colors.text[i, ],
strikeout = df.live.output.colors.strike[i, ])
}
n.half <- round(ncol(df.live[i, ])/2,0)
n.color.col1 <- ifelse(n.colored.column > n.half, n.half, n.colored.column)
n.color.col2 <- ifelse(n.colored.column > n.half, (n.colored.column - n.half) + 1, 1)
df.live1 <- df.live[, 1:(n.half)] %>%
kable(format = "html", escape = F) %>%
kable_styling(font_size = 18) %>%
column_spec(n.color.col1:n.half,
background = color.future) %>%
column_spec(1:n.color.col1,
background = color.past) %>%
column_spec(1, bold = T,
background = color.moolenaar,
width = "1em")
df.live2 <- df.live[, c(1, (n.half+1):ncol(df.live))] %>%
kable(format = "html", escape = F) %>%
kable_styling(font_size = 18) %>%
column_spec(1, bold = T) %>%
row_spec(1:nrow(df.live), background = color.table.background) %>%
column_spec(1:n.color.col2,
background = color.past) %>%
column_spec((n.color.col2+1):n.half,
background = color.future) %>%
column_spec(1, bold = T,
background = color.moolenaar,
width = "1em")
我希望背景填充整个单元格,而不是仅填充文本正下方的部分。我知道这可以通过format =“ latex”来实现,但是以某种方式可以通过format =“ html”吗?