Adding a New Template
Environment Setup and Package Installation
Environment Setup
Please ensure that R version 4.2 or higher is installed on your computer. This is required to install the packages you will need to create your TLG template. You can check your current version of R by running sessionInfo()
within the R console.
Installing Packages for Template Creation
To create your TLG template the {gtsummary}, {cards}, and {cardx} packages available on CRAN are required.
Please ensure you have these necessary packages installed by running the following code:
To create your example TLG/ARD, we recommend using datasets from the {pharmaverseadam} package (or the {random.cdisc.data} package) which contains example synthetic ADaM datasets and is available on CRAN. Optionally, you may want to also install the {crane} package which contains several helpful pharmaceutical-specific table creation functions:
For more information on these packages, see the Additional Resources section below.
Creating Your TLG Template
When adding a new template, start by initializing a new folder in the quarto/catalog
folder with a name that uniquely identifies your TLG (e.g. fda-table_01
, lab-tests-summary
). Within this folder, add a file named index.qmd
which will contain your new TLG template. To simplify the template-creation process we have provided an empty template file (inst/empty-template.qmd
) which can be copied into your new index.qmd
file and then modified.
We recommend using datasets from the pharmaverseadam
package to run your template code and generate a sample output TLG and ARD.
Ensure that your template file contains four main sections in separate tabs. If, for example, you are creating a template for a table, these tabs should be named:
- Table Preview - provides a preview of the table that is created in the template.
- Setup - lists the data set-up and pre-processing steps needed prior to creating the table.
- Build Table - provides the code needed to build the table.
- Build ARD - provides the code needed to build the ARD associated with the table. If an ARD-first approach was used to create the table this section should appear prior to the “Build Table” tab.
Finalizing Your TLG Template
Once you have created your template and ensured that all code runs without error, generate an image file named result.png
containing a snapshot of your table. Confirm that the output image looks correct.
Once you have finalized your TLG template, open a pull request in the cardinal GitHub repository.
Additional Resources
See the following sites for more information on packages leveraged by the cardinal team for TLG template development:
- {gtsummary}: Table creation
- {cards}: ARD creation
- {cardx}: Extended ARD creation functions
- {crane}: Pharmaceutical-specific table creation functions
- {pharmaverseadam}: Example synthetic ADaM datasets