I am trying to embed datatable in the R Markdown ioslides. However for a table with more than 8 col, it would not be able to fit within one page. Is there in the r chuck to re-size table to fit within ioslide? I have tried to use width in the options, but seems to have no effect.
## Example table, use another data wider tan iris
```{r, message=FALSE, warning=FALSE, echo=FALSE}
library(DT)
datatable(iris, options=list(pageLength = 5))
```
Above code is for reference only, not to reproduce the issue. In some use cases, the datatable is wider than screen and hope to be able to re-size to fit within one slide. Thanks.
DT package suggests to fixed certain columns and add scroll. See Section 4 here
m = as.data.frame(round(matrix(rnorm(100), 5), 5))
datatable(
m, extensions = 'FixedColumns',
options = list(
dom = 't',
scrollX = TRUE,
scrollCollapse = TRUE
))
You can also look at the default css that datatable uses and try to adjust the width there. Maybe this is helpfull: https://datatables.net/examples/basic_init/flexible_width.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With