Iteratively printing out of tables inside r chunk in r markdown

Viewed 51

i want to print out tables for a PDF document in R markdown.

My code looks like this: ("Table" is the list containing the tables to print out)

´´´{r, results = 'asis', echo = FALSE}
for ( j in 1:n){
  print(Table[[j]])
  cat('.   \n')  // i also can't manage do get empty rows between the tables
  print(Table[[2+n+1+j]])
´´´

But this only gives out the content of the table as text, it does not consider the table structure.

How can i fix that?

1 Answers

To get data in proper table structure in pdf you may use knitr::kable or any other package which helps in pretty display of dataframes.

```{r}
for ( j in 1:n){
  print(knitr::kable(Table[[j]]))
  cat('\n\n\n')
  print(Table[[2+n+1+j]])
}
```
Related