如何在 htmlTable 中的特定单元格之间划线?
How to make a line between specific cells in htmlTable?
我已经成功地为单元格着色,但我还想在单元格 3 和 3 以及 8 和 9 之间画一条线。我该怎么做?
df <- data.frame(a=c(4,3,9,9),b=c(5,3,8,8))
## indices defining where the styles go
where <- rbind(c(2,1),c(2,2))
style <- rep(('background-color: orange'),2)
css.cell <- matrix('', nrow(df), ncol(df))
css.cell[where] <- style
library(htmlTable)
htmlTable(df, css.cell = css.cell)
我想要它:
使用border-bottom
:
style <- rep(('background-color: orange; border-bottom: 2px solid;'), 2)
编辑
关于你的另一个问题:
df <- data.frame(a=c(4,3,9,9),b=c(5,3,8,8),c=c(5,6,7,8))
## indices defining where the styles go
where1 <- rbind(c(2,1),c(2,2))
style1 <- rep(('background-color: orange; border-bottom: 2px solid;'), 2)
where2 <- rbind(c(2,3))
style2 <- "border-bottom: 2px solid;"
css.cell <- matrix('', nrow(df), ncol(df))
css.cell[where1] <- style1
css.cell[where2] <- style2
library(htmlTable)
htmlTable(df, css.cell = css.cell)
我已经成功地为单元格着色,但我还想在单元格 3 和 3 以及 8 和 9 之间画一条线。我该怎么做?
df <- data.frame(a=c(4,3,9,9),b=c(5,3,8,8))
## indices defining where the styles go
where <- rbind(c(2,1),c(2,2))
style <- rep(('background-color: orange'),2)
css.cell <- matrix('', nrow(df), ncol(df))
css.cell[where] <- style
library(htmlTable)
htmlTable(df, css.cell = css.cell)
我想要它:
使用border-bottom
:
style <- rep(('background-color: orange; border-bottom: 2px solid;'), 2)
编辑
关于你的另一个问题:
df <- data.frame(a=c(4,3,9,9),b=c(5,3,8,8),c=c(5,6,7,8))
## indices defining where the styles go
where1 <- rbind(c(2,1),c(2,2))
style1 <- rep(('background-color: orange; border-bottom: 2px solid;'), 2)
where2 <- rbind(c(2,3))
style2 <- "border-bottom: 2px solid;"
css.cell <- matrix('', nrow(df), ncol(df))
css.cell[where1] <- style1
css.cell[where2] <- style2
library(htmlTable)
htmlTable(df, css.cell = css.cell)