r - Kables 没有看到我的 kable_styling 属性?
问题描述
我正在尝试并排吐出两张桌子,使用knitr::kables
.
不过,我不知道如何让我的风格保持不变。如果我运行一个 kable,则样式可以正常工作:
kable(
caption = "Oh look! A Caption",
starwars %>%
count(gender, sex) %>%
arrange(desc(gender))
) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
但是,如果我尝试并排设置两个,格式(或kable_styling
)会丢失:
knitr::kables(list(
kable(caption = "Oh look! A Caption",
starwars %>%
count(gender, sex) %>%
arrange(desc(gender))) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed")),
kable(caption = "Oh look! A Caption",
starwars %>%
count(gender, sex) %>%
arrange(desc(gender))) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
))
格式化都消失了:
我如何kable_styling
申请两个kables
?
解决方案
结果非常不满意的解决方案是添加第三个kable_styling()
调用:
knitr::kables(list(
kable(caption = "Species",
starwars %>%
count(species) %>%
filter(n > 1)
) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed")),
kable(caption = "Homeworld",
starwars %>%
count(homeworld) %>%
filter(n > 1)
) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
)
) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
这似乎很冗长,但它确实有效。
推荐阅读
- swift - Swift--UIPickerView 索引超出范围
- ios - 将数据从 UITableViewCell 传递到 ViewController
- python - 抓取(法语)动词变位并将它们导入 org-mode(与 org-drill 一起使用)
- python - python - matplotlib.pyplot 用 4 个通道保存二进制掩码(?)
- amazon-web-services - 未捕获:TypeError:AWS.CognitoIdentityCredentials 不是构造函数
- github - 将数据从 GoogleColab 上传到 GitHub 或 Kaggle
- javascript - 在 www.facebook.com 上运行的浏览器扩展的 Facebook 登录
- c - How to write C program that attaches/detaches from Unix terminal?
- python - TypeError: 不支持的操作数类型 -: 'int' and 'str' with a datetime module
- javascript - 如何从 HTML 输入字段中旋转 jpeg 文件并将其保存为 base64 字符串