【问题标题】:How to make a line between specific cells in htmlTable?如何在htmlTable中的特定单元格之间划线?
【发布时间】:2021-09-28 18:08:39
【问题描述】:

我已经设法为单元格着色,但我还想在单元格 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)

我想要这样:

【问题讨论】:

    标签: r html-table


    【解决方案1】:

    使用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)
    

    【讨论】:

    • 谢谢!我意识到我想把衬里和颜色分开,可以吗?看看我对自己问题的回答:)
    • @user11916948 是的,看我的编辑。
    猜你喜欢
    • 1970-01-01
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-16
    • 2021-06-01
    • 2019-03-25
    • 1970-01-01
    相关资源
    最近更新 更多