【问题标题】:How to make a specific row bold using Kable in r-markdown如何在 r-markdown 中使用 Kable 使特定行变为粗体
【发布时间】:2021-12-26 19:47:04
【问题描述】:

如何在 rmarkdown 中使用 Kable 使第三行变为粗体?以下是我的表格代码。

    library(kableExtra)
    table301 <- read.csv("edt.csv")
    
    x <- knitr::kable(table301,"pipe",  
    caption = "Education and Access", 
    position = "center", full_width = F) 
    kableExtra::row_spec(x, 5, bold = TRUE)

我正在使用以下数据框。

Name No.of Schools Composite_Score Percentage
A 18 52 58%
B 8 29 72%
C 27 116 86%
E 17 50 59%
F 6 25 83%
D 14 43 61%

谢谢

【问题讨论】:

    标签: r r-markdown kable kableextra


    【解决方案1】:

    使用 row_spec(3,bold=T,hline_after = T)

    library(kableExtra)
    library(tidyverse)
    
    kable(df)%>%
      kable_styling()%>%
      row_spec(3,bold=T,hline_after = T)
    

    数据:

    df <- structure(list(Name = c("A", "B", "C", "E", "F", "D"), No.of_Schools = c(18L, 
    8L, 27L, 17L, 6L, 14L), Composite_Score = c(52L, 29L, 116L, 50L, 
    25L, 43L), Percentage = c("58%", "72%", "86%", "59%", "83%", 
    "61%")), class = "data.frame", row.names = c(NA, -6L))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 2018-02-11
      • 1970-01-01
      相关资源
      最近更新 更多