Want to share your content on R bloggers? click here if you have a blog, or here if you don’t.
Disclaimer: This blog contains opinions that are those of the authors alone and do not necessarily reflect the strategy of their respective organizations.
We are pleased to introduce a new addition to the Pharmaverse: {docorator}an R package developed by GSK to facilitate the creation of production displays within pharmaceutical workflows. If you’ve ever spent hours perfecting a table or figure, only to struggle to add compliant headers, footers and perfect margins for a polished product, {docorator} maybe something for you.
For full documentation, visit the website here: https://gsk-biostatistics.github.io/docorator/
What is docorator?
The package name, {docorator}indicates the core functionality: decorate And Exit. The package uses TLGs generated by popular R packages such as {gt} (and by extension {tfrmt} And {gtsummary}) And {ggplot2} and “decorates” them with custom headers, footers, etc. in production-ready output.
The {docorator} package is built on a foundation of reproducibility and flexibility through the multi-rendering framework. While the primary and most robust rendering engine is PDF (using Rmarkdown/Quarto and LaTeX internally), basic RTF support is also available, with the underlying framework designed to expand to other output formats in the future.
How docorator is an addition to the pharmaceutical sector
This package can be considered complementary to the pharmaverse packages {clinify} And {gridify}. It provides an additional option for R users who want to meet organizational requirements for specific output types, as well as standardized headers, footers, margins, and dimensions. An important feature of {docorator} is the PDF support with embedded table values. Rendering to PDF via RMarkdown/Quarto and LaTeX embeds the displayed values into the PDF document, improving traceability. For {gt} For tables in particular, automatic table scaling (i.e. resizing columns) is applied by default to help fit the display to the available space.
Example: PDF view
The process of rendering a view involves two main steps:
- Make one
docoratorobject: This step uses theas_docorator()feature to add headers, footers and other style elements. - Display an output: A simple function call generates the final document.
Below is an illustrative example:
# This code assumes a display object called `t_demog` has been created
t_demog |>
as_docorator(
display_name = "t_demog",
display_loc = "path/to/output/folder",
header = fancyhead(
fancyrow(left = "Study ABC123", center = NA, right = doc_pagenum()),
fancyrow(left = "Safety Population", center = NA, right = NA),
fancyrow(left = NA, center = "Demographic Summary", right = NA)
),
footer = fancyfoot(
fancyrow(left = "path/to/t_demog.R", right = doc_datetime())
)
) |>
render_pdf()Please note that headers and footers are specified via the header And footer arguments using the fancyhead() And fancyfoot() functions respectively. These features, inspired by (and for PDF, powered by) the fancyhdr The LaTeX library allows users to flexibly add multiple rows of headers and/or footers with left, centered, and/or right aligned text. Rows of headers/footers are added via the fancyrow() function that takes arguments for where to add the custom text.
Here is the result:
.
Example: multiple renders
In the pharmaceutical industry it is very common for displays to be used for multiple reports, presentations and various downstream systems. {docorator} is designed for reuse and offers several powerful features:
- Multi-render capability: Users can render to multiple output types using pipeable syntax.
# Continuing from the previous example:
t_demog |>
as_docorator(
display_name = "t_demog",
display_loc = "path/to/output/folder",
header = fancyhead(
fancyrow(left = "Study ABC123", center = NA, right = doc_pagenum()),
fancyrow(left = "Safety Population", center = NA, right = NA),
fancyrow(left = NA, center = "Demographic Summary", right = NA)
),
footer = fancyfoot(
fancyrow(left = "path/to/t_demog.R", right = doc_datetime())
)
) |>
render_pdf() |>
render_rtf() # This will generate both PDF and RTF outputs- The
docoratorobject artifact:
Execute as_docorator() does not display your view immediately. Instead, it creates one docorator object that stores all relevant display information in a .rds file. This object serves as an artifact for future rendering or other downstream requirements. For the example above, t_demog.rds is saved in the folder “path/to/output/folder” next to the output documents “t_demog.pdf” and “t_demog.rtf”.
A note on LaTeX dependencies
As noted in the README, {docorator} requires a LaTeX installation for PDF viewing. If you use {tinytex}the TinyTeX bundle is recommended, it can be installed via the following code:
tinytex::install_tinytex(bundle = "TinyTeX")
Contact us!
We encourage you to try it {docorator} and provide any suggestions or report issues via the GitHub problems.
Reuse
Quote
BibTeX quote:
@online{krouse2025,
author = {Krouse, Becca},
title = {Introducing Docorator to the Pharmaverse},
date = {2025-12-19},
url = {https://pharmaverse.github.io/blog/posts/2025-12-19_introducing/introducing_docorator.html},
langid = {en}
}
For source citation, you can cite this work as:
Krouse, Becca. 2025. “Introducing Docorator to the Pharmaverse.” December 19, 2025. https://pharmaverse.github.io/blog/posts/2025-12-19_introducing/introducing_docorator.html.
Related
#Introducing #doctor #pharmaceutical #sector #bloggers


