在使用kable_styling()
函数时,可以使用参数bootstrap_options
来指定样式选项。如果需要重复相同的样式,可以将这些选项定义为一个变量,然后在kable_styling()
函数中使用该变量。
下面是一个示例代码:
library(kableExtra)
# 定义样式选项
common_style <- bootstrap_options(
table_class = "table table-striped table-bordered",
full_width = FALSE
)
# 使用kable_styling()函数,并传入common_style变量
kable(mtcars[1:5, 1:3], format = "html", booktabs = TRUE) %>%
kable_styling(bootstrap_options = common_style)
在上面的示例中,我们首先创建了一个名为common_style
的变量,其中包含了需要重复使用的样式选项。然后,在使用kable_styling()
函数时,将common_style
变量传递给bootstrap_options
参数。这样就可以避免重复输入相同的样式选项。
请注意,这个示例是使用kableExtra
包中的函数进行表格样式设置的。
上一篇:避免使用kable重叠的列
下一篇:避免使用开发者工具菜单