I am trying to include a variable name in the html output file name, produced by R Quarto. But no luck so far… In the example below, I specify group name (“Group A”), render, and want the resulting html to be called ‘Chart for Group A.html’. Then I want to re-run with a different group name (“Group B”) and want the html to be called ‘Chart for Group B.html’).
Here is what I tried, but getting the following error massage:
Error in
quarto_render()
:
✖ Error running quarto cli.
Caused by error:
! System command ‘quarto.exe’ failed
---
fontsize: 20pt
echo: FALSE
format:
html:
self-contained: true
Group_Name <- "Group A"
library(ggplot2)
library(quarto)
df <- data.frame( Year = c(2020, 2021, 2020, 2021),
Var = c(2.01, 3.05, 4.22, 5.29),
Group = c('Group A', 'Group A', 'Group B', 'Group B'))
df <- df[df$Group == Group_Name, ]
ggplot(df, aes(x=Year, y=Var)) +
geom_bar(stat = "identity")
file_name = paste0("Chart for ", Group_Name, ".html")
quarto_render("TEST output.qmd", output_file = file_name, output_format = "html")