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

Notes

  • The template argument must match one of the entries in list_all_templates().

  • If a file with the same name already exists, it will not be overwritten unless you set overwrite = TRUE.

  • In interactive mode, the generated file will open in your R editor for immediate editing.

Customize the template

Once the script is generated, you can modify it to suit your dataset or statistical needs. For instance, you can:

  • Add or remove table columns

  • Customize labels and formatting

  • Modify the summary statistics