I\'ve been using the xtable
package to create HTML tables out of R matrices. When I used the function kable
in a loop, it didn\'t output anything.
You should tell the chunk to use results as-is.
Do this by adding results='asis'
to your chunk header.
Try this:
```{r, results='asis', echo=FALSE}
library(knitr)
library(xtable)
for(i in 1:3) {
#Must use print because of the loop, but get ## per line
print(kable(head(cars), "html", table.attr='class="flat-table"'))
}
```
You should get
speed dist
4 2
4 10
7 4
7 22
8 16
9 10