Currently, anything emitted in the notebook gets printed exactly as it would at the console. That console output is captured and saved inside the notebook.
While this makes notebook execution symmetric with line-by-line execution of an R script or code chunk, it makes it asymmetric with knitting. When knitting, the S3 method knit_print can be used to customize how objects are emitted to the document. We could invoke that same method ourselves so that knit_print works in the notebook, too.
However, this will not be enough to have something shown in the IDE when not knitting but executing chunk by chunk.
It seems the chunk execution uses print() and not knit_print() so package author must find a way to have their print method behave correctly. It is not the case as the issue linked here when you open some HTML in the IDE viewer.
The IDE override some print method for some specific classes (here and here which makes it work out of the box for object using knit_asis class, or htmlwidgets, html, knit_kable and other.
Maybe a trick can be build to have package authors create print method that works for R console and R notebook but it will always be different that using knit_print.
Just trying to resurface this question so we decide for the best way to handle this and document or fix it.
Currently, anything emitted in the notebook gets printed exactly as it would at the console. That console output is captured and saved inside the notebook.
While this makes notebook execution symmetric with line-by-line execution of an R script or code chunk, it makes it asymmetric with knitting. When knitting, the S3 method
knit_printcan be used to customize how objects are emitted to the document. We could invoke that same method ourselves so thatknit_printworks in the notebook, too.Example of current behavior:
Via Twitter thread: https://twitter.com/klmr/status/920606977671262208
The text was updated successfully, but these errors were encountered: