我想在我的 gt 表格中添加一点填充,这样边框就不会相互冲突。理想情况下,这意味着边框在单元格内只有一点边距,因此它们看起来像修改后的屏幕截图中的橙色边框。我想不出一种方法来指定这个...有什么建议吗?
require(gt)
gt(exibble) %>%
cols_align(
align = "center",
columns = c("char")
) %>%
tab_style(
style = list(
cell_borders(
sides = c("all"),
weight = px(3)
),
cell_borders(
sides = c("all"),
weight = px(2)
)
),
locations = list(
cells_body(
columns = "char",
rows = !is.na(char)
),
cells_body(
columns = "datetime",
rows = !is.na(datetime)
)
)
)
您可以将
tab_options
函数与 data_row.padding
参数一起使用。
library(gt)
tab_1 <-
exibble |>
dplyr::select(-c(fctr, date, time, datetime)) |>
gt(
rowname_col = "row",
groupname_col = "group"
) |>
tab_header(
title = md("Data listing from **exibble**"),
subtitle = md("`exibble` is an R dataset")
)
tab_1 |> tab_options(data_row.padding = px(10))