mikemahoney218 / mm218.dev

Code and assets for my personal website at https://mm218.dev
https://mm218.dev
Other
26 stars 15 forks source link

posts/2022-08-04-how-to-use-quarto-for-parameterized-reporting/ #10

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Mike Mahoney - How to use Quarto for Parameterized Reporting

You know. If you wanna.

https://www.mm218.dev/posts/2022-08-04-how-to-use-quarto-for-parameterized-reporting/

marierivers commented 1 year ago

Any advise for using parameters with Python code used in a Quarto report? Is this possible?

mikemahoney218 commented 1 year ago

Hey @marierivers ! Yes! I'm going to steal from the official Quarto docs here, because I don't use the Juypter engines that often: https://quarto.org/docs/computations/parameters.html#jupyter

From the docs: For Jupyter, Quarto uses the same syntax for defining parameters as Papermill. To parameterize a notebook, designate a cell with the tag parameters and provide appropriate default values:

#| tags: [parameters]

alpha = 0.1
ratio = 0.1

The parameters are available in the top level environment:

str(alpha)
pelld commented 1 year ago

Excellent guide, very helpful. I'd like to produce multiple HTML files but how can I name them using parameters?

mikemahoney218 commented 1 year ago

I'm not immediately sure, @pelld ! If you ask over at https://github.com/quarto-dev/quarto-cli/discussions they might be able to help.

ssinari commented 1 year ago

@pelld You might use quarto_render command as shown in this stackoverflow discussion: https://stackoverflow.com/questions/73588271/customizing-r-quarto-pdf-output-file-name

The same post also shows more output file naming options.

MokeEire commented 1 year ago

This was far more entertaining than it had any right to be! Parameterized SQL looks very interesting, thanks for sharing this.

KilemiD commented 1 year ago

Thank you Mike. I enjoyed reading this. My problem, which ultimately led me here is to render customized reports for a number of say health facilities without doing a single report for each. Any advice on how I would actually execute that? I am thinking params is the way to go, but may you could shed more light on how I would execute that?

akins11 commented 4 months ago

Thank you so much, This was incredibly helpful and much appreciated.