yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.39k stars 878 forks source link

Is issue #1137 ever gonna be adressed? #2109

Closed jpm92 closed 2 years ago

jpm92 commented 2 years ago

Hello, I'm trying to print dynamically a summary of a model in rmarkdown together with a title inside a loop. I'm interested in having the title printed in markdown (asis output) while the summary in markup code (a typical code chunk with trailing ##). Unfortunatelly if I set the whole chunk to results="asis" the result is quite ugly. I thought I had it solved when I discovered knitr::asis_output(), but later I found it is not compatible with loops.

Is this going to change anytime soon? The original issue #1137 dates back to 2015, so I was wondering if this is something planned to fix.

Thanks a lot for your time.

Regards.


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

yihui commented 2 years ago

Sorry, but no, it won't change. I have mentioned workarounds in my reply there (results='asis' is one of them): https://github.com/yihui/knitr/issues/1137#issuecomment-162269666

More tech background: https://yihui.org/en/2017/06/top-level-r-expressions/

cderv commented 2 years ago

Hello, I'm trying to print dynamically a summary of a model in rmarkdown together with a title inside a loop. I'm interested in having the title printed in markdown (asis output) while the summary in markup code (a typical code chunk with trailing ##). Unfortunatelly if I set the whole chunk to results="asis" the result is quite ugly.

I don't know if I got your use case correctly, but you may be interested in using Child Documents. This will allow you include some mixed content (Markup and Code) in another Rmd document. Some example are in the cookbook

But you may be already using this...

Asking on https://community.rstudio.com can be a way to have some workaround to programmatically include your content as expected.

Hope it helps

jpm92 commented 2 years ago

Hello, I'm trying to print dynamically a summary of a model in rmarkdown together with a title inside a loop. I'm interested in having the title printed in markdown (asis output) while the summary in markup code (a typical code chunk with trailing ##). Unfortunatelly if I set the whole chunk to results="asis" the result is quite ugly.

I don't know if I got your use case correctly, but you may be interested in using Child Documents. This will allow you include some mixed content (Markup and Code) in another Rmd document. Some example are in the cookbook

But you may be already using this...

Asking on https://community.rstudio.com can be a way to have some workaround to programmatically include your content as expected.

Hope it helps

Thanks for your comment @cderv To be honest I haven't explored any other options. I'm also new to R Markdown. I did read those articles you mention but it seemed to much a hassle at that moment (maybe I didn't uderstand it well). What I ended up doing is retrieving all parameters of the model summary (which unfortunately is not compatible with xtable nor kable) and constructing a table myself in order to avoid the ugly looking output of "asis" results.

I'll try to find an axample of expand and child documents that fits me.

Thanks again for your time.

JP.

cderv commented 2 years ago

What I ended up doing is retrieving all parameters of the model summary (which unfortunately is not compatible with xtable nor kable) and constructing a table myself in order to avoid the ugly looking output of "asis" results.

FWIW huxtable as some support for regression table (https://hughjonesd.github.io/huxtable/huxreg.html) and also stargazer. Both are mentioned in the table part of the cookbook. https://bookdown.org/yihui/rmarkdown-cookbook/table-other.html

In case it could help.

github-actions[bot] commented 2 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.