Skip to content

using !expr in chunk YAML #547

Closed
Closed

Description

@BradyAJohnston

I'm trying to test out using the !expr in the chunk YAML to include calculated results for figure legends. In the documentation it says it is possible:

#| fig-cap: !expr paste("Air", "Quality")

But when in attempting to use it, I am so far met with errors both when attempting to render and RStudio detecting errors:

---
title: "test"
---

```{r}
#| label: fig-test
#| fig-cap: !expr paste("Air", "Quality")
plot(mtcars)
```
ERROR: YAMLError: unknown tag !<!expr> at line 1, column 39:
     ... p: !expr paste("Air", "Quality")
                                         ^

Activity

  1. jjallaire commented on Apr 6, 2022

    @jjallaire
    Collaborator

    Thanks for reporting this! That is our YAML validation being a bit too sensitive. For now you can get past this with:

    ---
    title: "test"
    validate-yaml: false
    ---

    We'll have a full fix for this soon. cc @cscheid

  2. cscheid commented on Apr 6, 2022

    @cscheid
    Member

    We added a fix for this in 32f0c0e. Let me know if this doesn't work!

  3. jjallaire commented on Apr 6, 2022

    @jjallaire
    Collaborator

    Note that currently these expressions are evaluated at the beginning of knit (there is a PR into knitr to ensure they are evaluated at cell execution time: yihui/knitr#2120)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions