Here’s a simple YAML chunk (with the label config
):
default:
user: "garrick"
github: "gadenbuie"
And now I’ll read that data into an R object that I could use in my document.
config_yaml <- knitr::knit_code$get("config")
config <- yaml::yaml.load(config_yaml)
config
## $default
## $default$user
## [1] "garrick"
##
## $default$github
## [1] "gadenbuie"
Good trick !
You do have the warning about unknown engine
So relying on a side effect behavior that we still fill
knitr::knit_code
with the content of chunk with unknown engine. Clever trick really.I would have done this way using the
cat()
engineThe easiest way though is probably to
embed
engine to show the content in the first chunk