The DT (datatables) library for R provides the minimal example for working with shiny below at http://rstudio.github.io/DT/extensions.html (this works for me)
library(shiny)
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
iris, options = list(lengthChange = FALSE)
)
}
)
However, the following code in a shiny RMarkdown document doesn't display any output. Why is that?
```{r}
library(rmarkdown); library(knitr); library(DT)
mydt = DT::renderDataTable(iris)
DT::dataTableOutput('mydt')
```
renderPrint(DT::dataTableOutput('mydt'))
also doesn't display the table, though it displays some html info about the table.
I don't understand why defining the datatable with DT::renderDataTable() and displaying it with DT::dataTableOutput() works in a shiny app but not a shiny document. Though I presume I'm misunderstanding something.