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
# No Worst Grade Flags found in the ADAE data set.
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.
Variant 7 was not created. With this variant, the SOC level is not trimmed (even if there are no terms left).
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.
Variant 10 was not done With this variant, SOC levels above the threshold are still in the table even if there are no terms left.
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) %>%filter(TRT01A !="<Missing>")adae <-df_explicit_na(adae) %>%var_relabel(AEBODSYS ="MedDRA System Organ Class",AEDECOD ="MedDRA Preferred Term" ) %>%filter( ANL01FL =="Y", AETOXGR !="<Missing>" )# Pre-Processinggrade_groups <-list("Grade 1-2"=c("1", "2"),"Grade 3-4"=c("3", "4"),"Grade 5"="5")adae$TOTAL_VAR <-"- Any adverse events - "# Helper function to avoid filtering also the first part of the table, where general information is given.my_row_condition <-function(row_fnc_condition) {function(table_row) {if (indent_mod(table_row) ==0) {return(TRUE) } else {row_fnc_condition(table_row) } }}# Helper function to calculate sum from first nested rowscore_all_sum <-function(tt) { cleaf <-collect_leaves(tt)[[1]]if (NROW(cleaf) ==0) {stop("score_all_sum score function used at subtable [", obj_name(tt), "] that has no content.") }sum(sapply(row_values(cleaf), function(cv) cv[1]))}# Raw table used by variant 8/10raw_table <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%split_rows_by(var ="TOTAL_VAR",label_pos ="hidden",child_labels ="visible",indent_mod =-1L ) %>%summarize_num_patients(var ="USUBJID",.stats ="unique",.labels ="- Any Grade -",.indent_mods =7L ) %>%count_occurrences_by_grade(var ="AETOXGR",grade_groups = grade_groups,.indent_mods =6L ) %>%split_rows_by("AEBODSYS",child_labels ="visible",nested =FALSE,split_fun = drop_split_levels,split_label =var_labels(adae)[["AEBODSYS"]],label_pos ="topleft" ) %>%split_rows_by("AEDECOD",child_labels ="visible",split_fun =add_overall_level("- Overall -", trim =TRUE),split_label =var_labels(adae)[["AEDECOD"]],label_pos ="topleft" ) %>%summarize_num_patients(var ="USUBJID",.stats ="unique",.labels ="- Any Grade -",.indent_mods =6L ) %>%count_occurrences_by_grade(var ="AETOXGR",grade_groups = grade_groups,.indent_mods =5L ) %>%append_topleft(" Grade") %>%build_table(adae, alt_counts_df = adsl) %>%prune_table() %>%sort_at_path(path ="AEBODSYS",scorefun = score_all_sum,decreasing =TRUE ) %>%sort_at_path(path =c("AEBODSYS", "*", "AEDECOD"),scorefun = score_all_sum,decreasing =TRUE )
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.