I love using knitr
to generate dynamic reports and share them with my co-workers using GitHub. What I usually do is to knit my Rmarkdown script --knit ('myfile.Rmd')
-- and generate a markdown (myfile.md
) version that can be directly seen on GitHub. The markdown file on GitHub works much better for me than a HTML file that knitr generates with pandoc.
This workflow usually works flawless except when I want to display a table. At the moment I'm using kable
inside the R-chunk which works pretty nicely if the end product is an HTML file.
My R-chunk looks like:
```{r}
library (knitr)
data (cars)
kable (head (cars))
```
When kable
is called from the console, I get the piped table I want:
| speed| dist|
|-----:|----:|
| 4| 2|
| 4| 10|
| 7| 4|
| 7| 22|
which is nicely displayed by GitHub.
However, what knit('myfile.Rmd')
generates in myfile.md
(when kable
is called from the R-chunk) is a simple table
speed dist
------ -----
4 2
4 10
7 4
7 22
which is not nicely displayed by GitHub.
Is there any way to make the tables in my markdown file compatible with the GitHub flavoured markdown?. Maybe there is a knitr
or kable()
option I'm not aware of? Or maybe there is an alternative to kable
that achieves the desired results?