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(tern)library(dplyr)library(forcats)adsl <- random.cdisc.data::cadsladlb <- random.cdisc.data::cadlbadlb_labels <-var_labels(adlb)# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)adlb <-df_explicit_na(adlb)# Select worst post-baseline records.adlb_f <- adlb %>%filter(ATOXGR !="<Missing>") %>%filter(ONTRTFL =="Y") %>%filter(WGRLOFL =="Y"| WGRHIFL =="Y")var_labels(adlb_f) <- adlb_labels# Derive GRADE_DIR and GRADE_ANL to use in layout from ATOXGRadlb_f <- adlb_f %>%mutate(GRADE_DIR =factor(case_when( ATOXGR %in%c("-1", "-2", "-3", "-4") & .data$WGRLOFL =="Y"~"LOW", ATOXGR =="0"~"ZERO", ATOXGR %in%c("1", "2", "3", "4") & .data$WGRHIFL =="Y"~"HIGH",TRUE~"NONE" ),levels =c("LOW", "ZERO", "HIGH", "NONE") ),GRADE_ANL = forcats::fct_relevel( forcats::fct_recode(ATOXGR,`1`="-1", `2`="-2", `3`="-3", `4`="-4" ),c("0", "1", "2", "3", "4") ) ) %>%var_relabel(GRADE_DIR ="Direction of Abnormality",GRADE_ANL ="Analysis Grade" )# Construct analysis mapmap <-expand.grid(PARAM =levels(adlb$PARAM),GRADE_DIR =c("LOW", "HIGH"),GRADE_ANL =as.character(1:4),stringsAsFactors =FALSE) %>%arrange(PARAM, desc(GRADE_DIR), GRADE_ANL)
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.