asis_knit_child: knit_child as is

Description Usage Arguments Details Examples

View source: R/rmarkdown_options.R

Description

This slightly modifies the knitr::knit_child() function to have different defaults.

Usage

1
asis_knit_child(..., quiet = TRUE, options = NULL, envir = parent.frame())

Arguments

...

passed to knitr::knit_child()

quiet

passed to knitr::knit_child()

options

defaults to NULL.

envir

passed to knitr::knit_child()

Details

Why default to the calling environment? Typically this function defaults to the global environment. This makes sense if you want to use knit_children in the same context as the rest of the document. However, you may also want to use knit_children inside functions to e.g. summarise a regression using a set of commands (e.g. plot some diagnostic graphs and a summary for a regression nicely formatted).

Some caveats:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
# an example of a wrapper function that calls asis_knit_child with an argument
# ensures distinct paths for cache and figures, so that these calls can be looped in parallel
regression_summary = function(model) {
   child_hash = digest::digest(model)
   options = list(
       fig.path = paste0(knitr::opts_chunk$get("fig.path"), child_hash, "-"), 
       cache.path = paste0(knitr::opts_chunk$get("cache.path"), child_hash, "-"))
   asis_knit_child("_regression_summary.Rmd", options = options)
}

## End(Not run)

grebbel/formr_test documentation built on May 17, 2019, 8:34 a.m.