Reputation: 47
Does anyone know if there are issues using the DT package in conjunction with knitrBootstap? When I try to render a data table using the datatable
function, the table itself does not render when the document is knit.
I've tried using the simple example below in both a standard markdown document as well as the knitrBootstrap styled document. It prints in the standard HTML output, but not in the bootstrap styled document:
library(DT)
datatable(iris)
Any thoughts on what might be causing this or how to workaround this? I've tried altering a few chunk options including results='asis
, but it didn't seem to help.
I am able to workaround this by using kable, setting an id and then utilizing javascript outside of the markdown chunk to render the table
kable(value_test, "html", table.attr = "id=\"test_table\"")
followed by:
<script type="text/javascript">
$(document).ready(function() {
$('#test_table').DataTable();
} );
Upvotes: 1
Views: 167
Reputation: 4767
I don't really know the current status of this, but a few years ago Leonardo Collado-Torres had worked out the proper way to do this with rCharts.
https://github.com/jimhester/knitrBootstrap/issues/21
Most likely the issue is that the jQuery libraries are being loaded twice, once by knitrBootstrap and again by DT.
You should inspect the html using Chrome or Firefox developer tools and see if there is a jQuery error, if so that is the likely cause.
If you are still having issues please open an issue at the knitrBootstrap bug tracker.
Upvotes: 1