Skip to contents

The function ae_table_grade_max() creates a summary table of the maximum AE grade experienced per each patient. The resulting crosstable can be piped to as_flextable() to get a nicely formatted flextable.

Usage

ae_table_grade_max(
  df_ae,
  ...,
  df_enrol,
  arm = "ARM",
  subjid = "SUBJID",
  soc = "AESOC",
  grade = "AEGR",
  total = TRUE,
  digits = 0
)

Arguments

df_ae

adverse event dataset, one row per AE, containing subjid, soc, and grade

...

unused

df_enrol

enrollment dataset, one row per patient, containing subjid (and arm if needed). All patients should be in this dataset.

arm

name of the treatment column in df_enrol. Case-insensitive. Can be set to NULL to not group.

subjid

name of the patient ID in both df_ae and df_enrol. Case-insensitive.

soc

name of the SOC column in df_ae. Case-insensitive. Grade will be considered 0 if missing(e.g. if patient if absent from df_ae).

grade

name of the AE grade column in df_ae. Case-insensitive.

total

whether to add a total column for each arm

digits

significant digits for percentages

Value

a crosstable (dataframe)

Examples


tm = edc_example_ae()
#> Warning: Option "edc_lookup" has been overwritten.
ae_table_grade_max(df_ae=tm$ae, df_enrol=tm$enrolres)
#> # A tibble: 7 × 6
#>   .id       label     variable Ctl      Trt      Total    
#>   <chr>     <chr>     <chr>    <chr>    <chr>    <chr>    
#> 1 grade_max Max grade Grade 1  3 (11%)  1 (4%)   4 (8%)   
#> 2 grade_max Max grade Grade 2  5 (19%)  5 (22%)  10 (20%) 
#> 3 grade_max Max grade Grade 3  10 (37%) 8 (35%)  18 (36%) 
#> 4 grade_max Max grade Grade 4  8 (30%)  1 (4%)   9 (18%)  
#> 5 grade_max Max grade Grade 5  1 (4%)   5 (22%)  6 (12%)  
#> 6 grade_max Max grade No AE    0 (0%)   3 (13%)  3 (6%)   
#> 7 grade_max Max grade Total    27 (54%) 23 (46%) 50 (100%)
ae_table_grade_max(df_ae=tm$ae, df_enrol=tm$enrolres, arm=NULL)
#> # A tibble: 7 × 4
#>   .id       label     variable value    
#>   <chr>     <chr>     <chr>    <chr>    
#> 1 grade_max Max grade Grade 1  4 (8%)   
#> 2 grade_max Max grade Grade 2  10 (20%) 
#> 3 grade_max Max grade Grade 3  18 (36%) 
#> 4 grade_max Max grade Grade 4  9 (18%)  
#> 5 grade_max Max grade Grade 5  6 (12%)  
#> 6 grade_max Max grade No AE    3 (6%)   
#> 7 grade_max Max grade Total    50 (100%)

if (FALSE) { # \dontrun{
#you can use as_flextable() to get an HTML flextable
#you can use modificators modificators from the flextable package
library(flextable)
ae_table_grade_max(df_ae=tm$ae, df_enrol=tm$enrolres, arm=NULL) %>% 
  as_flextable() %>% 
  add_footer_lines("Percentages are given as the proportion of patients 
                    presenting at most one AE of given grade")
ae_table_grade_max(df_ae=tm$ae, df_enrol=tm$enrolres) %>%
  as_flextable(by_header="Both arms") %>% 
  highlight(i=~variable=="Grade 5", j=-1)
} # }