cardinal
  • Home
  • Template Catalog
  • About
  • Resources
  • Help
    • Getting Started
    • Report a Bug
    • FAQ

On this page

  • Environment Setup and Package Installation
    • Environment Setup
    • Installing Packages for Template Creation
  • Creating Your TLG Template
  • Finalizing Your TLG Template
  • Template Navigation
  • Additional Resources

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:

Code
if (!require("cards")) install.packages("cards")
if (!require("cardx")) install.packages("cardx")
if (!require("gtsummary")) install.packages("gtsummary")

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:

Code
if (!require("pharmaverseadam")) install.packages("pharmaverseadam")
if (!require("crane")) install.packages("crane")

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:

  1. Table Preview - provides a preview of the table that is created in the template.
  2. Setup - lists the data set-up and pre-processing steps needed prior to creating the table.
  3. Build Table - provides the code needed to build the table.
  4. 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.

Template Navigation

A list of all templates currently available in cardinal is provided in the Template Catalog.

You can access the files for all currently available templates in the cardinal GitHub repository here.

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
Source Code
---
title: "Adding a New Template"
toc: true
toc-depth: 4
---

### 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:

```{r, echo=TRUE, eval=FALSE}
if (!require("cards")) install.packages("cards")
if (!require("cardx")) install.packages("cardx")
if (!require("gtsummary")) install.packages("gtsummary")
```

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:

```{r, echo=TRUE, eval=FALSE}
if (!require("pharmaverseadam")) install.packages("pharmaverseadam")
if (!require("crane")) install.packages("crane")
```

For more information on these packages, see the [Additional Resources](#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:

1. Table Preview - provides a preview of the table that is created in the template.
2. Setup - lists the data set-up and pre-processing steps needed prior to creating the table.
3. Build Table - provides the code needed to build the table.
4. 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](https://github.com/pharmaverse/cardinal/).

### Template Navigation

A list of all templates currently available in cardinal is provided in the [Template Catalog](index-catalog.qmd).

You can access the files for all currently available templates in the cardinal GitHub repository [here](https://github.com/pharmaverse/cardinal/tree/main/quarto/catalog).

### Additional Resources {#additional-resources}

See the following sites for more information on packages leveraged by the cardinal team for TLG template development:

-   [{gtsummary}](https://www.danieldsjoberg.com/gtsummary/): Table creation
-   [{cards}](https://insightsengineering.github.io/cards/): ARD creation
-   [{cardx}](https://insightsengineering.github.io/cardx/): Extended ARD creation functions
-   [{crane}](https://insightsengineering.github.io/crane/): Pharmaceutical-specific table creation functions
-   [{pharmaverseadam}](https://pharmaverse.github.io/pharmaverseadam/): Example synthetic ADaM datasets
 
  • This website as well as code examples are licensed under the Apache License, Version 2.0.
Cookie Preferences