Open cboettig opened 6 years ago
If you want to turn data frames to DataTables, you can customize the knit_print
method, e.g.
library(knitr)
knit_print.data.frame = function(x, ...) {
DT::datatable(x)
}
Thanks! Is customizing the knit_print
methods now the preferred way of setting these than doing library(printr)
?
Also, for some reason, I am not getting this to work in blogdown sites, though it works fine if I compile that page alone (e.g. with rmarkdown::render()
). Any hints or should I open a blogdown issue with MRE when I get a chance?
No, printr is essentially a collection of knit_print
methods. I just meant that you could override these methods.
I don't know why it doesn't work with blogdown, but I can reproduce your issue, so I don't need a MRE. Thanks!
This should work:
knit_print.data.frame = function(x, ...) {
knit_print(DT::datatable(x), ...)
}
It would be great to have
printr
's magic work with the elegant jquery tables from the DT package for HTML documents...http://rstudio.github.io/DT/