[英]Unable to get row_spec command to work in conjunction with booktabs with kable
我正在使用 RMarkdown 打印表格,我讨厌 kable 标准的水平线。 我使用“booktabs = T”命令来防止打印行,但是当我这样做时,我的 row_spec 命令不起作用。 我很好奇为什么会这样。 我添加了下面的代码来向您展示会发生什么。 此示例没有显示感兴趣行颜色变化的 booktabs。
df <- data.frame("x" = c("Variable Name",
"Variabe Description / Label","Variable Format",
"Data Collection Waves",
"Possible Range of Nonmissing Values"),
"y" = c("SUBID","Subject ID","NUM","1992 - 2009","2-6920"))
## tables
print(
kable(df, format = "latex", longtable = TRUE, row.names = NA, col.names = NULL) %>%
kable_styling(latex_options = c("striped"), font_size = 11, full_width = TRUE, position = "center") %>%
row_spec(0, bold = T, color = "#006400")
)
但是,当我添加 booktabs 命令时, row_spec 不起作用。 有没有解决方案,我可以在使用 booktabs 的同时更改第一行中字体的颜色?
df <- data.frame("x" = c("Variable Name",
"Variabe Description / Label","Variable Format",
"Data Collection Waves",
"Possible Range of Nonmissing Values"),
"y" = c("SUBID","Subject ID","NUM","1992 - 2009","2-6920"))
## tables
print(
kable(df, format = "latex", longtable = TRUE, row.names = NA, col.names = NULL, booktabs=T) %>%
kable_styling(latex_options = c("striped"), font_size = 11, full_width = TRUE, position = "center") %>%
row_spec(0, bold = T, color = "#006400")[![enter image description here][1]][1]
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.