configuration
metayer-config.Rmd
When metayer is loaded, it populates several options and sets up logging. Much of this can be configured by making changes to config.yml.
configurability
Package configuration is specified in config.yml, which is designed
to mimic the behavior of the config
package. As such, the top-level sections–default, testing, and
jupyter–are intended to correspond to an execution / operational mode.
Our extension, config_get
, enables YAML references and
provides a few default handlers for custom YAML tags.
A link to the current YAML config.
custom YAML tags
Note that there are custom YAML tags available, !optenv
and !with_env
.
!optenv
optenv is used to evaluate simple R expressions, like
logger::INFO
; the idea is to simplify the specification of
objects or functions.
config.yml
logger
options
cli.default_handler
We set this to cli_nullity_handler
in order to enjoy
null visibility in cli output.
cli.condition_unicode_bullets
Useful in testing to ensure that output doesn’t have unusual unicode characters.
knitr.chunk.error
An aesthetic choice for R output.
A cosmetic change for imbuing R output with class tags suitable for CSS.
mty.fig.*
with_grdev
default parameters. See the function reference.
knitr
shim
The shim will be included in Rmd files after the YAML header and before the main text. It allows us to clearly set knitr options in the most local context. This is in contrast to setting environmental variables which can tricky to manage when documents are generated in isolated subprocesses.
N.B., in the example below, triple tilde should be triple backtick, but there were rendering issues.
shim: |
~~~{r setup, include = FALSE}
library(magrittr)
library(rlang)
library(metayer)
~~~
~~~{r, include = FALSE}
Sys.setenv(R_CONFIG_ACTIVE = "jupyter")
# knitr options [ref](https://yihui.org/knitr/options/) documentation;
knitr::opts_chunk$set(
metayer_hook = TRUE,
comment = "",
fig.path = "assets/knitr/",
# c.f., _pkgdown \ templates \ includes
class.output = c("sourceCode", "rOutput")
)
knitr::opts_knit$set(
root.dir = here::here("vignettes")
)
knitr::knit_hooks$set(
metayer_hook = knitr_metayer_hook
)
~~~