2

I'm trying to produce an automated report using Rmarkdown. In this report I have sections with tables. The sections are produced using the following Rmarkdown. However, it refuses to produce any tables(tried using kable and pander) when I hit knit. Knit will just produce the headings, without any tables. When I use the immediate mode, I get the appropriate markdown. So what might I be doing wrong.

```{r, results='asis'}
for(p in names(presentations)) {
  deats <- presentations[p][[1]]
  cat('#', p, '\n')
  pander(deats)
  str(deats)
  cat('\n')
}
```
HSchmale
  • 1,838
  • 2
  • 21
  • 48

2 Answers2

3

If using pander, disable the auto asis results:

```{r, results='asis'}
library(pander)
panderOptions('knitr.auto.asis', FALSE)

for(p in names(mtcars)) {
  cat('#', p, '\n')
  pander(table(mtcars[, p]))
}
```

For more details, see the related Using pander with knitr vignette

daroczig
  • 28,004
  • 7
  • 90
  • 124
2

When knitr::kable() or pander::pander() is not top-level R expression, you have to explicitly print it. You may see this post for more background information.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419