lyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by(var ="ACTARM") %>%add_overall_col(label ="All Patients") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Overall total number of events" ) ) %>%split_rows_by("AEBODSYS",child_labels ="visible",nested =FALSE,split_fun = split_fun,label_pos ="topleft",split_label =obj_label(adae$AEBODSYS) ) %>%summarize_num_patients(var ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Total number of events" ) ) %>%count_occurrences(vars ="AEDECOD",.indent_mods =-1L ) %>%append_varlabels(adae, "AEDECOD", indent =1L)result <-build_table(lyt, df = adae, alt_counts_df = adsl)result
MedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients
MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400)
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) 301 (75.2%)
Overall total number of events 502 480 604 1586
cl A.1
Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) 202 (50.5%)
Total number of events 115 99 137 351
dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) 128 (32.0%)
dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) 122 (30.5%)
cl B.1
Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%)
Total number of events 44 43 50 137
dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%)
cl B.2
Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) 192 (48.0%)
Total number of events 102 106 127 335
dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) 119 (29.8%)
dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) 123 (30.8%)
cl C.1
Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%)
Total number of events 47 51 54 152
dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%)
cl C.2
Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%)
Total number of events 39 40 57 136
dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%)
cl D.1
Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) 186 (46.5%)
Total number of events 106 84 114 304
dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) 120 (30.0%)
dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) 112 (28.0%)
cl D.2
Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%)
Total number of events 49 57 65 171
dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
The variable result corresponds to the adverse events table. However, it includes many empty rows accounting for events which were not reported. The table can be post-processed to prune empty rows and to sort rows, for example by occurrence.
result <- result %>%prune_table() %>%sort_at_path(path =c("AEBODSYS"),scorefun = cont_n_allcols ) %>%sort_at_path(path =c("AEBODSYS", "*", "AEDECOD"),scorefun = score_occurrences )result
MedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients
MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400)
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) 301 (75.2%)
Overall total number of events 502 480 604 1586
cl A.1
Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) 202 (50.5%)
Total number of events 115 99 137 351
dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) 128 (32.0%)
dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) 122 (30.5%)
cl B.2
Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) 192 (48.0%)
Total number of events 102 106 127 335
dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) 123 (30.8%)
dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) 119 (29.8%)
cl D.1
Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) 186 (46.5%)
Total number of events 106 84 114 304
dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) 120 (30.0%)
dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) 112 (28.0%)
cl D.2
Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%)
Total number of events 49 57 65 171
dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%)
cl C.2
Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%)
Total number of events 39 40 57 136
dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%)
cl B.1
Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%)
Total number of events 44 43 50 137
dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%)
cl C.1
Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%)
Total number of events 47 51 54 152
dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
lyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by(var ="ACTARM") %>%add_overall_col(label ="All Patients") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Overall total number of events" ) ) %>%split_rows_by("AEBODSYS",child_labels ="visible",nested =FALSE,split_fun = split_fun,label_pos ="topleft",split_label =obj_label(adae$AEBODSYS) ) %>%summarize_num_patients(var ="USUBJID",.stats =c("unique"),.labels =c(unique ="Total number of patients with at least one adverse event" ) ) %>%count_occurrences(vars ="AEDECOD", .indent_mods =-1L) %>%append_varlabels(adae, "AEDECOD", indent =1L) %>%count_values("STUDYID",values =as.character(unique(adae$STUDYID)),.stats ="count",.labels =c(count ="Total number of events"),.indent_mods =c(count =-1L) )result <-build_table(lyt, df = adae, alt_counts_df = adsl) %>%prune_table() %>%sort_at_path(path =c("AEBODSYS", "*", "AEDECOD"),scorefun = score_occurrences ) %>%sort_at_path(path =c("AEBODSYS"),scorefun = cont_n_allcols )result
MedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients
MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400)
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) 301 (75.2%)
Overall total number of events 502 480 604 1586
cl A.1
Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) 202 (50.5%)
dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) 128 (32.0%)
dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) 122 (30.5%)
Total number of events 115 99 137 351
cl B.2
Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) 192 (48.0%)
dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) 123 (30.8%)
dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) 119 (29.8%)
Total number of events 102 106 127 335
cl D.1
Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) 186 (46.5%)
dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) 120 (30.0%)
dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) 112 (28.0%)
Total number of events 106 84 114 304
cl D.2
Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%)
dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%)
Total number of events 49 57 65 171
cl C.2
Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%)
dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%)
Total number of events 39 40 57 136
cl B.1
Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%)
dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%)
Total number of events 44 43 50 137
cl C.1
Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%)
dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%)
Total number of events 47 51 54 152
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
lyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by(var ="ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Overall total number of events" ) ) %>%split_rows_by("AEBODSYS",child_labels ="visible",nested =FALSE,split_fun = split_fun,label_pos ="topleft",split_label =obj_label(adae$AEBODSYS) ) %>%summarize_num_patients(var ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Total number of events" ) ) %>%split_rows_by("AEHLT",child_labels ="visible",nested =TRUE,split_fun = split_fun,indent_mod =-1L,label_pos ="topleft",split_label =obj_label(adae$AEHLT) ) %>%summarize_num_patients(var ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Total number of events" ) ) %>%count_occurrences(vars ="AEDECOD", .indent_mods =-1L) %>%append_varlabels(adae, c("AEDECOD"), indent =2L)result <-build_table(lyt, df = adae, alt_counts_df = adsl) %>%prune_table() %>%sort_at_path(path =c("AEBODSYS"),scorefun = cont_n_allcols ) %>%sort_at_path(path =c("AEBODSYS", "*", "AEHLT"),scorefun = cont_n_allcols ) %>%sort_at_path(path =c("AEBODSYS", "*", "AEHLT", "*", "AEDECOD"),scorefun = score_occurrences )result
MedDRA System Organ Class
High Level Term A: Drug X B: Placebo C: Combination
MedDRA Preferred Term (N=134) (N=134) (N=132)
————————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%)
Overall total number of events 502 480 604
cl A.1
Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%)
Total number of events 115 99 137
hlt A.1.1.1
Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%)
Total number of events 115 99 137
dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%)
dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%)
cl B.2
Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%)
Total number of events 102 106 127
hlt B.2.2.3
Total number of patients with at least one adverse event 38 (28.4%) 40 (29.9%) 45 (34.1%)
Total number of events 50 55 68
dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%)
hlt B.2.1.2
Total number of patients with at least one adverse event 39 (29.1%) 34 (25.4%) 46 (34.8%)
Total number of events 52 51 59
dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%)
cl D.1
Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%)
Total number of events 106 84 114
hlt D.1.1.1
Total number of patients with at least one adverse event 42 (31.3%) 32 (23.9%) 46 (34.8%)
Total number of events 52 40 64
dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%)
hlt D.1.1.4
Total number of patients with at least one adverse event 38 (28.4%) 34 (25.4%) 40 (30.3%)
Total number of events 54 44 50
dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%)
cl D.2
Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%)
Total number of events 49 57 65
hlt D.2.1.5
Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%)
Total number of events 49 57 65
dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%)
cl C.2
Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%)
Total number of events 39 40 57
hlt C.2.1.2
Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%)
Total number of events 39 40 57
dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%)
cl B.1
Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%)
Total number of events 44 43 50
hlt B.1.1.1
Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%)
Total number of events 44 43 50
dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%)
cl C.1
Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%)
Total number of events 47 51 54
hlt C.1.1.1
Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%)
Total number of events 47 51 54
dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
lyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by(var ="ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Total number of events" ),show_labels ="hidden" ) %>%count_occurrences(vars ="AEDECOD") %>%append_varlabels(adae, "AEDECOD")result <-build_table(lyt, df = adae, alt_counts_df = adsl) %>%sort_at_path(path =c("AEDECOD"),scorefun = score_occurrences )result
A: Drug X B: Placebo C: Combination
MedDRA Preferred Term (N=134) (N=134) (N=132)
————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%)
Total number of events 502 480 604
dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%)
dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%)
dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%)
dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%)
dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%)
dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%)
dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%)
dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%)
dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%)
dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
adae_5 <- adae %>% dplyr::filter(ACTARM !="C: Combination")lyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by(var ="ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Overall total number of events" ) ) %>%split_rows_by("AEBODSYS",child_labels ="visible",nested =FALSE,split_fun = split_fun,label_pos ="topleft",split_label =obj_label(adae$AEBODSYS) ) %>%summarize_num_patients(var ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one adverse event",nonunique ="Total number of events" ) ) %>%count_occurrences(vars ="AEDECOD", .indent_mods =-1L) %>%append_varlabels(adae, "AEDECOD", indent =1L)result <-build_table(lyt, df = adae_5, alt_counts_df = adsl) %>%prune_table() %>%sort_at_path(path =c("AEBODSYS"),scorefun = cont_n_allcols ) %>%sort_at_path(path =c("AEBODSYS", "*", "AEDECOD"),scorefun = score_occurrences )result
MedDRA System Organ Class A: Drug X B: Placebo C: Combination
MedDRA Preferred Term (N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 0
Overall total number of events 502 480 0
cl A.1
Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 0
Total number of events 115 99 0
dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 0
dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 0
cl B.2
Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 0
Total number of events 102 106 0
dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 0
dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 0
cl D.1
Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 0
Total number of events 106 84 0
dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 0
dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 0
cl D.2
Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 0
Total number of events 49 57 0
dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 0
cl B.1
Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 0
Total number of events 44 43 0
dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 0
cl C.1
Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 0
Total number of events 47 51 0
dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 0
cl C.2
Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 0
Total number of events 39 40 0
dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 0
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Code
library(dplyr)library(tern)adsl <- random.cdisc.data::cadsladae <- random.cdisc.data::cadae# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)adae <-df_explicit_na(adae) %>%var_relabel(AEBODSYS ="MedDRA System Organ Class",AEDECOD ="MedDRA Preferred Term" ) %>%filter(ANL01FL =="Y")# Define the split functionsplit_fun <- drop_split_levels
library(teal.modules.clinical)## Data reproducible codedata <-teal_data()data <-within(data, { ADSL <- random.cdisc.data::cadsl ADAE <- random.cdisc.data::cadae# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels. ADSL <-df_explicit_na(ADSL) ADAE <-df_explicit_na(ADAE)})datanames <-c("ADSL", "ADAE")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADAE <- data[["ADAE"]]## Setup Appapp <-init(data = data,modules =modules(tm_t_events(label ="Adverse Event Table",dataname ="ADAE",arm_var =choices_selected(c("ARM", "ARMCD"), "ARM"),llt =choices_selected(choices =variable_choices(ADAE, c("AETERM", "AEDECOD")),selected =c("AEDECOD") ),hlt =choices_selected(choices =variable_choices(ADAE, c("AEBODSYS", "AESOC")),selected ="AEBODSYS" ),add_total =TRUE,event_type ="adverse event" ) ))shinyApp(app$ui, app$server)
Experimental use!
shinylive allow you to modify to run shiny application entirely in the web browser. Modify the code below and click re-run the app to see the results. The performance is slighly worse and some of the features (e.g. downloading) might not work at all.
#| '!! shinylive warning !!': |#| shinylive does not work in self-contained HTML documents.#| Please set `embed-resources: false` in your metadata.#| standalone: true#| viewerHeight: 800#| editorHeight: 200#| components: [viewer, editor]#| layout: vertical# -- WEBR HELPERS --options(webr_pkg_repos = c("r-universe" = "https://insightsengineering.r-universe.dev", getOption("webr_pkg_repos")))# -- APP CODE --library(teal.modules.clinical)## Data reproducible codedata <- teal_data()data <- within(data, { ADSL <- random.cdisc.data::cadsl ADAE <- random.cdisc.data::cadae # Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels. ADSL <- df_explicit_na(ADSL) ADAE <- df_explicit_na(ADAE)})datanames <- c("ADSL", "ADAE")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADAE <- data[["ADAE"]]## Setup Appapp <- init( data = data, modules = modules( tm_t_events( label = "Adverse Event Table", dataname = "ADAE", arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), llt = choices_selected( choices = variable_choices(ADAE, c("AETERM", "AEDECOD")), selected = c("AEDECOD") ), hlt = choices_selected( choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")), selected = "AEBODSYS" ), add_total = TRUE, event_type = "adverse event" ) ))shinyApp(app$ui, app$server)