Open SamuelAllain opened 1 year ago
Thanks for opening the issue.
html_notebook()
is a special format that does not knit but emulate knitr evaluation to get some in chunk preview which will be then shown in a HTML.
This mean that with Notebook you need to execute the chunk first in IDE , then it will be shown in the HTML preview. It seems there is indeed something off with where the plot are inserted and they get not assigned to the right section.
I'll dig into that. Thanks for the report
- html_document keeps only one graphic, randomly putting it into section "test 2"
This is just a edge case because you have one chunk only and plotting the same plot. I think;
Takes this simple example to reproduce
---
title: "R Notebook"
output:
html_document: default
---
```{r}
plot(1)
plot(1)
plot(1)
@yihui is this suppose to give us 3 plots ? or evaluate in filtering out somehow plots because there are identical recorded plot ?
Do we have a regression here ?
## Note about creating mixed content from within R chunk
Regarding creating mix Rmd content with markdown text and code, from a chunk in R, our recommended way is to use `knit_child()`. Example
````markdown
---
title: "R Notebook"
output:
html_document: default
---
```{r, echo = FALSE, results='asis'}
res <- lapply(1:5, function(i) {
knitr::knit_child(text = c(
"# Test `r i`",
"",
"```{r}",
"plot(mtcars[,c(i, 3)])",
"```",
"",
"Some text"
), envir = environment(), quiet = TRUE)
})
cat(unlist(res), sep = '\n')
Unfortunately this requires to knit the file. More in the Cookbook https://bookdown.org/yihui/rmarkdown-cookbook/child-document.html
@yihui is this suppose to give us 3 plots ? or evaluate in filtering out somehow plots because there are identical recorded plot ? Do we have a regression here ?
We don't have a regression. Consecutive identical plots are removed by default. To keep all identical plots, use the chunk option fig.keep = 'all'
: https://yihui.org/knitr/options/#plots
However, I just tested your example and found the last plot would be removed. I don't know why yet. I can investigate it if it's truly desirable to be able to keep all identical plots.
However, I just tested your example and found the last plot would be removed. I don't know why yet. I can investigate it if it's truly desirable to be able to keep all identical plots.
Yes I tried also fig.keep = 'all'
and it seems to me something was off. I don't think that is important as this is a non real example. Just wanted to check that it was expected to have only one plot kept. Thanks
Hello, I try to dynamically generate markdown sections with plots and I have very weird behaviours both when I compare html_document and html_notebook and when I compare with a constant plot and with a variable plot. The reprex talks for itself :
xfun::session_info('rmarkdown')
givesChecklist
When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:
[x] formatted your issue so it is easier for us to read?
[x] included a minimal, self-contained, and reproducible example?
[x] pasted the output from
xfun::session_info('rmarkdown')
in your issue?[x] upgraded all your packages to their latest versions (including your versions of R, the RStudio IDE, and relevant R packages)?
[x] installed and tested your bug with the development version of the rmarkdown package using
remotes::install_github("rstudio/rmarkdown")
?