datatable in for loop showing white-space after render to html

datatable in for loop showing white-space after render to html

sksahusksahu Posts: 1Questions: 1Answers: 0

This is an known issue in r-markdown and solution given here - https://stackoverflow.com/questions/39732560/why-does-datatable-not-print-when-looping-in-rmarkdown

With this solution tried to run the following code chunk in RStudio and it works fine. But once after render to html, it shows white-space in the place of datatable.

    ```{r test, results='asis'}
    for (row in 1:2) {
      cat(paste("\n\n#### test: ", row , "##\n"))
      print( htmltools::tagList(datatable(iris)) )
    }
    ```

But once I have another datatable next to forloop. Then its printing all the tables in html.
For Example:

    ```{r test, results='asis'}
    for (row in 1:2) {
      cat(paste("\n\n#### test: ", row , "##\n"))
      print( htmltools::tagList(datatable(iris)) )
    }
    datatable(iris)
    ```

I know this is an r-markdown html issue. But if any help will be much appreciated.

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @sksahu ,

    Are you sure this relates to this DataTable jQuery plugin? We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.