Passing a vector to parameters in Quarto

What is the correct way to pass a vector to parameters in Quarto? I want to pass a vector as a parameter in a Quarto doc like this:

  state_county: !expr c("42095", "42017", "48453", "09003")

I think the code successfully renders but the "Background Jobs" pain throws the following error:

ERROR: YAMLError: unknown tag !<!r> at line 17, column 57:
     ... 019", "20045", "19103", "47093")

This was easy in R Markdown with the following:

  state_county: !r c("42095", "42017", "48453", "09003")

The Quarto documentation only shows examples with vectors with length 1. This GitHub issue appeared relevant but validate-yaml did not help.

Iam not sure what the problem here is, but using this input:

title: "Untitled"
format: html
    my_vec: !expr c("1","2","3")


Gives me an html file with a printed vector as output. Using spaces after the comma also gives the same result. Maybe you are using an old version which has problems with this kind of input?

1 Like

This is a doozy. We're building a Quarto website with a _quarto.yml.

Quarto pretty much renders every .qmd and .Rmd in the project including old files using the Quarto flavor of YAML (doc here). An old .Rmd script with !r was in the project and was causing the error. It works great when rendering just the .Rmd but not in the context of a Quarto website. Deleting the .Rmd file with !r or setting render targets resolves the issue.

Note: This was very unclear when we clicked the render button in RStudio. It was very clear when we ran quarto render at the command line because it showed us the file that contained the error.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.