I'm using quarto as an alternative to rmarkdown to generate reports using R. However, I'm not sure how to access R objects already created before calling the quarto_render function. For example, in the below
var1=5
quarto::quarto_render(input="Audit.qmd")
i want to access var1 from inside Audit.qmd file. But Audit.qmd does not recognise var1.Not sure how to do this. In Rmarkdown this can be done naturally. Quarto being language independent, doesn't make it that simple. I can store those variables as rds objects, and then import it back from inside qmd file, but is there a simpler way by which all the objects are accessed from qmd session?
In R Markdown, this can be done "naturally" because rmarkdown::render() is a R function running inside the same R session by default. You would have the same issue as with quarto if you were running rmarkdown::render() in a new background R session. FWIW quarto_render() is only a R wrapper function to call the CLI tool on the system quarto render using system() call.
Quarto is not coded in R - it will just open a new R background session to evaluate R code.
This is the best way for complex R objects (like dataframe or list, or models or other specifics). If you need to pass values, you can use the parametrization