Generating Templates with table_templates.R
Yolanda Zhou
([yolandazzz13
])
2025-07-23
Source:vignettes/tlg_templates.Rmd
tlg_templates.Rmd
Overview
This vignette demonstrates how to use predefined templates to create
new R scripts for generating tables.The core idea is to provide a set of
standard templates for common statistical tables, such as those for
demography (t_dm_slide
). Users can then modify them to suit
their specific datasets and analysis needs.
List available templates
Before generating a template, you can view all supported table
templates using the list_all_templates()
function:
To get started, first navigate to your autoslider.core
repo directory, make sure you have installed the
autoslider.core
package:
setwd("~/path/to/autoslider.core")
devtools::load_all()
list_all_templates()
This will return a character vector of supported templates (e.g.,
t_dm_slide
, g_ae_slide
, etc.), each
corresponding to a table type stored in the R/
folder of
the package.
Generate a template for your own table
Use the use_template()
function to generate a template
script that you can customize. For example:
use_template(template = "t_dm_slide", function_name = "demography")
This will create a file with the demography template at
./programs/R/demography.R
To create multiple variations of the same template type, you could
choose your custom numbering/enumeration style simply by passing in
different function_names
. For example:
use_template(template = "l_ae_slide", function_name = "l_ae_slide_001")
# which generates an Adverse Events listing at ./programs/R/l_ae_slide_001.R
use_template(template = "l_ae_slide", function_name = "l_ae_slide_v2")
# which generates an Adverse Events listing at ./programs/R/l_ae_slide_v2.R