Skip to content

Instantly share code, notes, and snippets.

@edonnachie
Created November 22, 2021 11:59
Show Gist options
  • Save edonnachie/8d3254e1727f723972b7a980e1da6518 to your computer and use it in GitHub Desktop.
Save edonnachie/8d3254e1727f723972b7a980e1da6518 to your computer and use it in GitHub Desktop.
Make chunks from one .Rmd document available to a different .Rmd document
read_chunk_Rmd <- function(path, ...) {
f_tmp <- tempfile()
knitr::purl(input = path, output = f_tmp)
on.exit(file.remove(f_tmp))
knitr::read_chunk(f_tmp, ...)
}
@edonnachie
Copy link
Author

Created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment