UseR 2024
Founded a consultancy business 
Also work with R for the Rest of Us 
Produced 1000+ parametrized reports
Contact me: thomas@kantiles.com 








Dashboard
Pull approach
Bring global & detailed understanding
Interactive viz and tables
For analysts & data practitioners
https://
Reports
Push approach
Bring local comprehension & awareness
Static tailored viz
For people on the field & partners
Portable Document Format (PDF)
Ask:
Areas

Sectors

Units

Combine them but check you have enough data
And re-use them with params$XXX :

Text
![]()
Computations
![]()
![]()
PDF engines
![]()

Typst
Quarto format
Lightning quick
Custom langage for layout
Great for simple templates
weasyprint
Pandoc engine
Quick
No preview
Best tool for most of the cases
French
pagedjs-cli
Pandoc engine
No direct preview
Most complete tool
JS based








Set up the format + use partials:
typst-show.typ transfer the parameterstypst-template.typ is the template
font-pathsallow you to use custom fonts by putting them in a folder
typst-show.typ
typst-template.typ: all is valid until replaced
// format with custom parameters
#let my-report(
  title: "Title",
  subtitle: none,
  country_name: none
  body,
) = {
  // text default
  set text(
    font: "Calibri",
    size: 11pt,
  )
  // --- Configure first page ---
  set page(
    "us-letter",
    background: place(right, rect(fill: rgb(#123456), width: 30%, height: 100%)),
    margin: (left: 1in, right: 1in, top: 0.7in, bottom: 1in),
  )
  // --- title grid ---
  v(5%)
  // logo
  image("logo.svg", height: 10%)
  v(10%)
  pad(text(16pt, weight: "regular", country_name), right: 30%)
  v(5%)
  pagebreak()  // --- Configure the rest of the pages ---
  set page(
    "us-letter",
    background: place(top, rect(fill: rgb(#123456), width: 100%, height: 0.5in)),
    footer: {
      line(length: 100%)
    },
    margin: (left: 1in, right: 1in, top: 0.7in, bottom: 1in),
  )
  // --- headings ---
  // level 1 is ## if there is no #
  // level 2 is ###
  // level 3 is ####
  show heading.where(level: 1): it => [
    #set text(17pt, weight: "bold")
    #block(it.body)
  ]
  show heading.where(level: 2): it => [
    #set text(fill: rgb(maincolor), size: 15pt, weight: "regular")
    #block(it.body)
  ]
  show heading.where(level: 3): it => [
    #set text(fill: rgb(maincolor), size: 12pt, weight: "regular")
    #block(it.body)
  ]
  // --- body ---
  body
}All the others tools are based on CSS Paged Media
Differences but more or less compatible between them
I did a full talk about how to template things (in French) for pagedown. See the video 
Print to PDF:
weasyprint (or pagedjs-cli)pdf-engine: weasyprintVars that have been created in the Quarto file can also be used
Use
content: "";to display the background color or image.
.title and others
display: none;helps to remove the global content in margins
Define named pages
with fenced div :::named1 + :::
or classic HTML <div class="named1"> + </div>
CSS side :
Define utility functions :
img -> remove defaults marginsYou can arrange some positions with negative margins and positive paddings. Play with them !
Since page size is fixed, think to use
position: absolute;if needed
quarto.report weasyprintquarto.report Change parameters in the YAML (or _quarto.yml file)
quarto.report - typewriter



quarto.report - chalk



quarto.report - corner



Avoid as much as possible computations within the report
Pay attention to formats - use scales
Make sure your data is unique by parameter
Compute explicit missing data with tidyr::complete
If you got this warning from
ggplot2, you probably messed up something with limitsWarning message: Removed 7 rows containing missing values or values outside the scale range (`geom_point()`).
Limits can be set dynamically
svg or svglite (with fig-format)fig-width and fig-height for all plotsTo the global level

To others

In time

You can pick them all
Be informative about comparisons :
```{epoxy, .data=txt_data_1_3}
In {year}, measles elimination was <span class = "txt-navy">achieved
</span>in {nb_achieved} countries in the WHO region, while it was
<span class = "txt-yellow">re-established</span> in
{nb_reestablished} countries and <span class = "txt-red">
not achieved</span> in {nb_not_achieved} countries.
```Use :
 <span>...</span>


mapquarto_renderUse
fs::file_moveto move your reports to the right folder (see )
Check reports with extreme values :