Dynamic contents in R Markdown with knit_child()

Generate random dataset

all_data <- purrr::map(1:5, ~ random_data(round(runif(1, 10, 100))))
render_child <- function(data, i) {
  res = knitr::knit_child(
   text = xfun::read_utf8("_template.Rmd"),
   envir = rlang::env(data = data, i = i),
   quiet = TRUE
  )
  cat(res, sep = '\n')
  cat("\n")
}

Here is a list of reports

Dataset 1

Dataset 1 has 84 rows.

Summary

Summary statistics show that the

       x                 y          
 Min.   :-2.4458   Min.   :-2.5182  
 1st Qu.:-0.5999   1st Qu.:-0.8267  
 Median :-0.0034   Median : 0.1501  
 Mean   :-0.0030   Mean   : 0.0186  
 3rd Qu.: 0.6921   3rd Qu.: 0.7682  
 Max.   : 2.3457   Max.   : 2.5894  

Plot

Dataset 2

Dataset 2 has 31 rows.

Summary

Summary statistics show that the

       x                y          
 Min.   :-1.757   Min.   :-1.8009  
 1st Qu.:-0.794   1st Qu.:-0.5512  
 Median :-0.288   Median : 0.0462  
 Mean   :-0.254   Mean   : 0.0475  
 3rd Qu.: 0.193   3rd Qu.: 0.8066  
 Max.   : 3.186   Max.   : 1.4467  

Plot

Dataset 3

Dataset 3 has 58 rows.

Summary

Summary statistics show that the

       x                 y          
 Min.   :-2.3982   Min.   :-2.8262  
 1st Qu.:-0.5439   1st Qu.:-0.6185  
 Median :-0.0318   Median : 0.1615  
 Mean   : 0.0624   Mean   : 0.0108  
 3rd Qu.: 0.7881   3rd Qu.: 0.7760  
 Max.   : 2.7836   Max.   : 2.2855  

Plot

Dataset 4

Dataset 4 has 27 rows.

Summary

Summary statistics show that the

       x                 y         
 Min.   :-1.6920   Min.   :-1.879  
 1st Qu.:-0.7055   1st Qu.:-0.724  
 Median :-0.0484   Median :-0.002  
 Mean   :-0.0414   Mean   : 0.040  
 3rd Qu.: 0.5737   3rd Qu.: 0.541  
 Max.   : 2.8013   Max.   : 3.484  

Plot

Dataset 5

Dataset 5 has 38 rows.

Summary

Summary statistics show that the

       x                y          
 Min.   :-2.672   Min.   :-1.4412  
 1st Qu.:-0.327   1st Qu.:-0.7895  
 Median : 0.374   Median :-0.1989  
 Mean   : 0.288   Mean   :-0.0871  
 3rd Qu.: 0.891   3rd Qu.: 0.3204  
 Max.   : 2.154   Max.   : 1.6226  

Plot