quarto-dev / quarto-dev/quarto-cli

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

Open
#12,044 5 comments 0 reactions 1 assignee View on GitHub

@cderv is already working on this.

Since Feb 7, 2025.

bug engines-knitr needs-discussion yaml-validation
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.