{docorator} is an engine for creating production displays from R. Specifically, {docorator} provides the following functionality:
The main function, as_docorator()
accepts an R object
containing the display as input. For best results with sizing, the table
should be prepared via {gt}, or packages that interface with {gt} such
as {tfrmt}, and the figure should be prepared with {ggplot2}.
Alternatively, the path to a PNG can be passed to {docorator}.
Specifically, the x
should be one of the following:
gt
tablegt_group
(list of gt
tables)ggplot2
figureggplot
figuresThe docorator
object, which is saved by default, can
then be output using one or both of the following render functions which
can be piped together: render_pdf()
and
render_rtf()
# install from GitHub
::install_github("GSK-Biostatistics/docorator")
devtools
# Load package
library(docorator)
# Create table (or figure)
<- gt::exibble |>
mytbl ::gt()
gt
# Export display
|>
mytbl as_docorator(
display_name = "mytbl",
header = fancyhead(
fancyrow(left = "My Study", center = NA, right = doc_pagenum()),
fancyrow(left = "My Population", center = NA, right = NA),
fancyrow(left = NA, center = "My Table", right = NA)
),footer = fancyfoot(
fancyrow(left = "mypath/mytbl.R", center = NA, right = "Data as of 2025-01-01")
) |>
) render_pdf() |>
render_rtf()
{docorator} requires LaTeX libraries for PDF rendering. If using {tinytex}, the “TinyTeX” bundle covers the core dependencies.