Printing nice cross-tabulations in knitr Printing nice cross-tabulations in knitr r r

Printing nice cross-tabulations in knitr


An alternative to kable is pander from the package with the same name, which provides an easy way of generating markdown tables with bunch of options (like style) and a generic S3 method:

> pander(x)-------------------    A   B   C ------- --- --- --- **D**  15   9   7  **E**  13  14   9  **F**   8   8  17 -------------------> pander(f)----- ----- --- --- ---      "Col" "A" "B" "C""Row"                   "D"        15   9   7  "E"        13  14   9  "F"         8   8  17 ----- ----- --- --- ---

If you want to generate the old rmarkdown-style pipe tables, add stlye='rmarkdown' parameter, although AFAIK Pandoc is the new standard there as well, which supports the above multi-line table.


I suggest you use stargazer as follows:

  • Use quote=FALSE
  • Make sure to specify type="html"

Try this:

# stargazer```{r, echo=TRUE, results='asis'}stargazer(format(f, quote=FALSE, justify="right"), type="html")```

enter image description here


Further digging led me to this question.

The answer is embarrassingly obvious - the 'tables' package!

I thought there had to be a simpler way to do this. Many thanks nonetheless to Andrie and daroczig for their helpful responses.