We suggest pre-writing the Rmd file to another Rmd file before knitting and rendering as follows
master.Rmd:
# Analysis Routines Analysis for this can be seen in figures `r paste(paste0("\\ref{", CHUNK_NAME, 1:NUM_CHUNKS, "}"), collapse=", ")` @@@ rmdTxt <- unlist(lapply(1:NUM_CHUNKS, function(n) { c(paste0("## Analysis Routine ", n), paste0("```{r ",CHUNK_NAME, n, ", child = 'child.Rmd'}"), "```") })) writeLines(rmdTxt) @@@
child.Rmd:
```{r,echo = FALSE} plot(rnorm(100)) ```
Knit and make Rmd:
devtools::install_github("chinsoon12/PreKnitPostHTMLRender") library(PreKnitPostHTMLRender) #requires version >= 0.1.1 NUM_CHUNKS <- 5 CHUNK_NAME <- "myChunk-" preknit_knit_render_postrender("master.Rmd", "test__test.html")
Hope this helps. Hooray!
source share