I'm using targets
to render a Quarto report, which contains some eval chunk options that are based on variables created during the pipeline execution. During the execution, I started getting some errors that the variable was not found. Initially I though it was a problem with targets
and started a discussion (inconsistency when using target object as input to quarto chunk options · Discussion #137 · ropensci/tarchetypes · GitHub). But on further exploration, it looks like it's a problem when issuing knitr::knit( tangle = TRUE)
.
Bellow is a small reprex:
report_eval_test.qmd
---
format: html
---
```{r}
choice <- TRUE
```
```{r}
#| eval: !expr choice
1 + 1 == 2
```
```{r}
#| eval: !expr (!choice)
1 + 1 == 3
```
If I issue knitr::knit('report_eval_test.qmd', tangle = TRUE)
I get:
processing file: report_eval_test.qmd
|...................................................... | 67%
Error in eval(x, envir = envir) : object 'choice' not found
|.................................................................................| 100%
Error in eval(x, envir = envir) : object 'choice' not found
output file: report_eval_test.R
Am I doing something wrong? It's important to notice that rendering this document in RStudio (render button) works just fine.
I just updated knitr to v1.42 and the issue remains
> sessionInfo()
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale:
[1] LC_CTYPE=pt_BR.UTF-8 LC_NUMERIC=C LC_TIME=pt_BR.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=pt_BR.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=pt_BR.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.42
loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2 yaml_2.3.7 xfun_0.36
Thanks