How to use child and plot properly following the reference exemple

Hi,
I have tried to generalize the exemple given here : https://bookdown.org/yihui/rmarkdown-cookbook/child-document.html
in order to get a document whith a list of graphics for each column of mtcars data set.

So, I replaced the chunk in the child file

lm(mpg ~ ., data = mtcars[, c("mpg", x)])
by
plot(mtcars[ x ])
And knit the file, like the original example :

res <- lapply(names(mtcars),function (x) {
knitr::knit_child('DocumentCHILD.Rmd', envir = environment(), quiet = TRUE)
})
cat(unlist(res), sep = '\n')

It gives the following with no grapics at all ! The unnamed-chunk *.png files don't exist after "kniting" the master file.
Regression on "mpg"
img src="DocumentMASTER_files/figure-html/unnamed-chunk-5-1.png" width="672"
Regression on "cyl"
img src="DocumentMASTER_files/figure-html/unnamed-chunk-8-1.png" width="672"
... until on "carb".

What is the solution to have a nice succession of graphics by iteration on the list of mtcars column names?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.