Skip to content

Cannot pass an R vector to fig-subcap with YAML validation, but works without #12044

Open
@jack-davison

Description

@jack-davison

Bug description

When YAML validation is on, I can't pass an R vector to fig-subcap:. I get the below error.

Watching files for changes
In file qmd.qmd
(line 20, columns 16--29) Field "fig-subcap" has value !expr 'yaxes', which must instead be 'true'

When I set validate-yaml: false it progresses and produces the desired output:

Image

Clearly fig-subcap doesn't want/need a value true.

Steps to reproduce

This fails:

---
title: "Quarto Playground"
format: html
engine: knitr
execute:
  echo: false
---

```{r}
library(ggplot2)

dat <- mtcars

yaxes <- names(mtcars)[names(mtcars) != "mpg"]
```

```{r}
#| label: fig-polarplots
#| fig-cap: !expr 'paste("Air", "Quality")'
#| fig-subcap: !expr 'yaxes'
#| layout-ncol: 2

purrr::map(yaxes, \(x) plot(mtcars[["mpg"]], mtcars[[x]]))
```

This works:

---
title: "Quarto Playground"
format: html
engine: knitr
validate-yaml: false
execute:
  echo: false
---

```{r}
library(ggplot2)

dat <- mtcars

yaxes <- names(mtcars)[names(mtcars) != "mpg"]
```

```{r}
#| label: fig-polarplots
#| fig-cap: !expr 'paste("Air", "Quality")'
#| fig-subcap: !expr 'yaxes'
#| layout-ncol: 2

purrr::map(yaxes, \(x) plot(mtcars[["mpg"]], mtcars[[x]]))
```

Expected behavior

Either:

  • Yaml validation shouldn't complain being given a R vector via !expr.

  • Passing an R vector to fig-subcap should never work (note: I'd much rather this wasn't the case unless there was some alternative to dynamically setting fig subcaps!)

Actual behavior

See bug description - errors w/ yaml validation.

Your environment

  • IDE: RStudio 2024.12.0.467
  • OS: Windows 11

Quarto check output

[>] Checking environment information...
      Quarto cache location: C:\Users\JD38\AppData\Local\quarto
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.6.39
      Path: C:\Users\JD38\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\JD38\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2024

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....(None)

      Unable to locate an installed version of Python 3.
      Install Python 3 from https://www.python.org/downloads/

[>] Checking R installation...........OK
      Version: 4.4.2
      Path: C:/PROGRA~1/R/R-44~1.2
      LibPaths:
        - C:/Users/JD38/AppData/Local/R/win-library/4.4
        - C:/Program Files/R/R-4.4.2/library
      knitr: 1.49
      rmarkdown: 2.29

[>] Checking Knitr engine render......OK

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingknitrneeds-discussionIssues that require a team-wide discussion before proceeding furtheryaml-validationIssues with YAML validation and autocompletion in quarto

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions