3

I am using rmarkdown to create pdf document, but couldn't get the horizontal line separation for each block. The code is below

---
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")           
```

I tried

```{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")           
```

How do I create horizontal lines separating each block?

J_F
  • 9,956
  • 2
  • 31
  • 55
arvin
  • 33
  • 1
  • 4

1 Answers1

1

I would suggest to use the R-package xtable, which is very powerful in advanced features and table styles. In your case I would write:

---
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)
```
J_F
  • 9,956
  • 2
  • 31
  • 55