gpt4 book ai didi

r - 在 pdf 输出中的 kable 表中创建水平线

转载 作者:行者123 更新时间:2023-12-02 03:56:08 25 4
gpt4 key购买 nike

我正在使用 rmarkdown 创建 pdf 文档,但无法获得每个 block 的水平线分隔。代码如下

---
title: "Some title"
author: Arvin
date: "October 18, 2016"
output: pdf_document
fig_caption: yes
---


```{r script1, echo = FALSE}
df1 <- data.frame(A1 = c("Sometext", "", "", "B1", "Sometext", ""),
A2 = c("a", "b", "c", "B2", "d", "e" ),
check.names = FALSE)
knitr::kable(df1, caption = "Summary Table")
```

我试过了

```{r script1, echo = FALSE}
df1 <- data.frame(A1 = c("Sometext", "", "", "-------", "B1", "------", "Sometext", ""),
A2 = c("a", "b", "c", "-------", "B2", "-------", "d" "e" ),
check.names = FALSE)
knitr::kable(df1, caption = "Summary Table")
```

如何创建分隔每个 block 的水平线?

最佳答案

我建议使用R包xtable,它在高级功能和表格样式方面非常强大。对于你的情况我会写:

---
title: "Some title"
author: Arvin
date: "October 18, 2016"
output: pdf_document
fig_caption: yes
---


```{r script1, echo = FALSE, results='asis'}
df1 <- data.frame(A1 = c("Sometext", "", "", "B1", "Sometext", ""),
A2 = c("a", "b", "c", "B2", "d", "e" ),
check.names = FALSE)

print(xtable::xtable(df1), hline.after = c(-1,0,3,6), comment=F)
```

关于r - 在 pdf 输出中的 kable 表中创建水平线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40109486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com