I'm trying to create a Quarto report, which will be parametrized by first and last name. In use, the report file will be called by an R script/:
The title of the report is defined by:
title: !expr paste("Report Run Log for", params$WhoFName, params$WhoLName)
In the Quarto file itself the default parameter values for WhoFName, WhoLName are defined down in the Yaml:
SourceDir: "..."
SourceFile: "..."
LogFile: "..."
WhoFName: "Fred"
WhoLName: "Jones"
When I run the report by rendering the Quarto file in the menu's render command, I get this message:
Error: object 'params' not found Error in yaml::yaml.load(..., eval.expr = TRUE) : Could not evaluate expression: paste("Run Log for", params$WhoFName, params$WhoLName) Calls: .main ... parse_yaml_front_matter -> yaml_load -> Execution halted
Note that when I print the parameter values further down, they exist and are correct. My theory is that they simply are not defined at the time when the title tries to access them. But...
When I call the report using this command, I get a similar error message:
input = "scripts/Report_Run.qmd",
execute_params = list(
WhoFName = "Paul",
WhoLName = "Jones"
)
)
I get a similar error:
Error: object 'params' not found Error in yaml::yaml.load(..., eval.expr = TRUE) : Could not evaluate expression: paste("Report Run Log for", params$WhoFName, params$WhoLName) Calls: .main ... parse_yaml_front_matter -> yaml_load -> Execution halted Error in
processx::run(quarto_bin, args, echo = TRUE): ! System command 'quarto.exe' failed
Exit status: 1 stdout & stderr:
When I used this render command on a version of the report without parameter values referenced in the title, the correct parameter values are passed and used.
Does anybody have some ideas here, or a good link?
Sincerely,
Barry DeCicco
In R you can include parameters in your title by structuring the YAML as shown.
---
format:
html:
embed-resources: true
pdf:
toc: true
documentclass: report
params:
WhoFName: "Bill"
WhoFName: "Bryson"
disease: "Asthma"
title: "Report Run Log for `r params$WhoFName` `r params$WhoLName`"
author: "author name"
---
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With