Datatable does not print in combination with cat command in Rmd / RStudio

Can someone explain why in the Rmd code (for creating an HTML report using RStudio) only the command is displayed cat? When I move a command catoutside of a sentence ifor comment on it, the table is printed. I believe the same thing happens when used library(printr), but I have not confirmed this with a minimal sample.

It seems that the code inside the sentence is ifsomehow interpreted and that is catnot suitable for datatable.

If you could give me some tips on how to debug this, that would be helpful too. Since there were no error messages / errors.

---
title: "test"
output: 
  html_document
---


```{r}
if(TRUE){
  DT::datatable(iris)
  cat("I am here with my cat")
}

```
+3
1

, knitr # 1137. HTML-, DT/DataTables, , R- . , . , , . . . , print() ( show() S4). knitr : knitr::knit_print, print(), , (, HTML) . rmarkdown HTML- (, <script src="dataTables.js"></script> <head>).

, , , , .

:

if (TRUE) {

  1:10  # not printed

  11:20 # printed because this is the visible value returned by if()

}
+5

Source: https://habr.com/ru/post/1663409/


All Articles