Skip to contents

In this section, we write a script to create a risk-difference table from the PHUSE Test Data Factory ADaM dataset, using the Typlr package. We use the logrx package to generate a log upon the script execution for reproducibility and traceability.

1. Load the packages

First, we load the packages that we will use to generate the risk-difference table.

2. Load the data

Then we load the Adverse Event Analysis Dataset from the PHUSE Test Data Factory ADaM dataset. The data are stored in a transport file format and we use the haven package to load them.

adae <- read_xpt("adae.xpt")

3. Build the risk-difference table

Finally, we write a script (risk_diff.R) to build the risk-difference table, using the Typlr package.

t <- tplyr_table(adae, TRTA) %>% 
    group_count(RACE) %>% 
      set_distinct_by(USUBJID) %>% 
        c("Xanomeline High Dose", "Placebo"),
        c("Xanomeline Low Dose", "Placebo")


4. Axecute the script

We will axecute the following script.


Below is the log. Pay special attention to the Warnings and Result sections.