简体   繁体   English

使用目标 object 作为四开块选项的输入时不一致

[英]inconsistency when using target object as input to quarto chunk options

I'm using targets to develop a pipeline.我正在使用目标来开发管道。 At the end of the pipeline I want to generate a report (Quarto markdown) in which some chunks get evaluated depending on objects created during the pipeline.在管道的末端,我想生成一份报告(Quarto markdown),其中根据管道期间创建的对象对某些块进行评估。

I can recover the pipeline object using我可以使用恢复管道 object

id <- tar_load(id)

and use the variable inside a chunk option:并在块选项中使用变量:

#| echo !expr id
# do some stuff if id == TRUE

But, the eval option works differently.但是, eval选项的工作方式不同。

#| eval: !expr id

# This should only get evaluated if id is TRUE
# but also raises an error when issuing tar_make()
# Error in eval(x, envir = envir) : object 'choice' not found
1 + 1 == 2

The chunk above gets evaluated correctly, that is, if result from expression is TRUE, it evaluates.上面的块被正确评估,也就是说,如果 result from expression 为 TRUE,它就会评估。 But it also raises an error when issuing tar_make()但它在发出tar_make()时也会引发错误

Error in eval(x, envir = envir) : object 'choice' not found

If I change the code chunk to #| eval: !expr tar_read(choice)如果我将代码块更改为#| eval: !expr tar_read(choice) #| eval: !expr tar_read(choice) , than no error is reported #| eval: !expr tar_read(choice) ,没有报错

Is this the expected behavior?这是预期的行为吗? Or is this an inconsistency?或者这是一个不一致?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM