I am trying to use DT::datatable
to output a nicely formatted, interactive table in R.
...only problem is that I want a heroku job to knit the document for me, and I've learned that RStudio and rmarkdown::render()
use pandoc under the hood -- but pandoc doesn't ship in the stripped down R Buildpack for heroku.
Is there any way to get the old markdown engine (knitr:knit2html
or markdown:markdownToHTML
) to pass the javascript that powers datatable
through? Or to be more precise, to generate the sample table below without using pandoc?
Here is a minimal example:
testing.Rmd
---
title: "testing"
output: html_document
---
this is a datatable table
```{r test2, echo=FALSE}
library(DT)
DT::datatable(
iris,
rownames = FALSE,
options = list(pageLength = 12, dom = 'tip')
)
```
this is regular R output
```{r}
head(iris)
```
knit_test.R
require(knitr)
knitr::knit2html('testing.Rmd')
generates:
this is a datatable table <!–html_preserve–>
<!–/html_preserve–>
this is regular R output
head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
desired behavior: have my datatable come through (not <!–html_preserve–>
)
what I've tried
I looked at htmltools and the htmlPreserve
stuff but couldn't figure out how to apply that here. did some crazy stuff with saveWidget
that was not successful and does not bear repeating.
Thanks!