Suppress evaluation of knitr chunk options in custom language engine

Viewed 38

I am writing a custom knitr language engine to support https://github.com/ropensci/targets/discussions/469, and I would like users to be able to write R Markdown code chunks like this:


```{tar_target analysis, pattern = map(data)}
run_analysis(data)
```

I want to avoid evaluating the pattern argument because map(data) is a DSL in tar_target() and not actual R code. But when I run the chunk, I get a "could not find function 'map'" error before control passes to the engine. Is it possible for me as the developer to call substitute() on the necessary options before knitr tries to evaluate them?

EDIT: thinking about supporting a wrapper to control special arguments to tar_target():


```{tar_target analysis, tar_args = tar_args(pattern = map(data), error = "workspace")}
run_analysis(data)
```
0 Answers
Related