diff --git a/R/tm_g_ae_oview.R b/R/tm_g_ae_oview.R index 83790246..c64473e1 100644 --- a/R/tm_g_ae_oview.R +++ b/R/tm_g_ae_oview.R @@ -209,7 +209,10 @@ ui_g_ae_oview <- function(id, ...) { footnotes = "" ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ) ) } @@ -294,13 +297,12 @@ srv_g_ae_oview <- function(id, input$arm_trt, message_fmt = "Must not be equal to Treatment" )) - iv_comp$enable() - validate(need(iv_comp$is_valid(), "Misspecification error: please observe red flags in the encodings.")) + validate(need(iv_comp$is_valid(), "Misspecification error: please observe red flags in the encodings.")) validate(need(nlevels(ANL[[input$arm_var]]) > 1, "Arm needs to have at least 2 levels")) validate_has_data(ANL, min_nrow = 10) - if (all(c(input$arm_trt, input$arm_ref) %in% ANL_UNFILTERED[[input$arm_var]])) { + if (all(c(input$arm_trt, input$arm_ref) %in% ANL[[input$arm_var]])) { iv_an <- shinyvalidate::InputValidator$new() iv_an$add_rule("arm_ref", shinyvalidate::sv_in_set(set = ANL[[input$arm_var]])) iv_an$add_rule("arm_trt", shinyvalidate::sv_in_set(set = ANL[[input$arm_var]])) @@ -310,7 +312,7 @@ srv_g_ae_oview <- function(id, validate(need(all(c(input$arm_trt, input$arm_ref) %in% unique(ANL[[input$arm_var]])), "Plot loading")) q1 <- teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code(data)), + teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = as.expression(c( bquote(anl_labels <- formatters::var_labels(.(as.name(dataname)), fill = FALSE)), bquote(flags <- .(as.name(dataname)) %>% @@ -344,6 +346,13 @@ srv_g_ae_oview <- function(id, plot_r <- reactive(output_q()[["plot"]]) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", verbatim_content = reactive(teal.code::get_code(output_q())), diff --git a/R/tm_g_ae_sub.R b/R/tm_g_ae_sub.R index e2c696d7..ebce6703 100644 --- a/R/tm_g_ae_sub.R +++ b/R/tm_g_ae_sub.R @@ -161,7 +161,10 @@ ui_g_ae_sub <- function(id, ...) { ) ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ) ) } @@ -336,7 +339,7 @@ srv_g_ae_sub <- function(id, bquote(group_labels <- setNames(.(group_labels), .(input$groups))) } - q1 <- teal.code::eval_code(teal.code::new_qenv(tdata2env(data), code = get_code(data)), code = group_labels_call) + q1 <- teal.code::eval_code(teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = group_labels_call) q2 <- teal.code::eval_code(q1, code = "") teal.code::eval_code( q2, @@ -365,6 +368,13 @@ srv_g_ae_sub <- function(id, plot_r <- reactive(output_q()[["plot"]]) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", verbatim_content = reactive(teal.code::get_code(output_q())), diff --git a/R/tm_g_butterfly.R b/R/tm_g_butterfly.R index 036c31a3..09429401 100644 --- a/R/tm_g_butterfly.R +++ b/R/tm_g_butterfly.R @@ -252,7 +252,10 @@ ui_g_butterfly <- function(id, ...) { value = a$legend_on ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code"), + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ), pre_output = a$pre_output, post_output = a$post_output ) @@ -407,7 +410,7 @@ srv_g_butterfly <- function(id, data, filter_panel_api, reporter, dataname, labe anl_vars <- unique(c("USUBJID", "STUDYID", varlist_from_anl)) # nolint q1 <- teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code(data)), + teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = bquote({ ADSL <- ADSL[, .(adsl_vars)] %>% as.data.frame() # nolint ANL <- .(as.name(dataname))[, .(anl_vars)] %>% as.data.frame() # nolint @@ -489,6 +492,13 @@ srv_g_butterfly <- function(id, data, filter_panel_api, reporter, dataname, labe width = plot_width ) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", title = paste("R code for", label), diff --git a/R/tm_g_events_term_id.R b/R/tm_g_events_term_id.R index 6d6f05e6..8ea558d7 100644 --- a/R/tm_g_events_term_id.R +++ b/R/tm_g_events_term_id.R @@ -190,7 +190,10 @@ ui_g_events_term_id <- function(id, ...) { footnotes = "" ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ) ) } @@ -315,7 +318,7 @@ srv_g_events_term_id <- function(id, anl_vars <- c("USUBJID", "STUDYID", input$term) # nolint q1 <- teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code(data)), + teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = bquote( ANL <- merge( # nolint x = ADSL[, .(adsl_vars), drop = FALSE], @@ -357,6 +360,13 @@ srv_g_events_term_id <- function(id, plot_r <- reactive(output_q()[["plot"]]) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", title = paste("R code for", label), diff --git a/R/tm_g_heat_bygrade.R b/R/tm_g_heat_bygrade.R index b0623c0e..a14ca8cb 100644 --- a/R/tm_g_heat_bygrade.R +++ b/R/tm_g_heat_bygrade.R @@ -288,7 +288,10 @@ ui_g_heatmap_bygrade <- function(id, ...) { footnotes = "" ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ) ) ) } @@ -377,7 +380,7 @@ srv_g_heatmap_bygrade <- function(id, paste("Please de-select", input$id_var, "in annotation variable(s)", sep = " ") )) - if (input$plot_cm) { + if (isTRUE(input$plot_cm)) { ADCM <- data[[cm_dataname]]() # nolint validate( need( @@ -395,7 +398,7 @@ srv_g_heatmap_bygrade <- function(id, )) } - q1 <- if (input$plot_cm) { + q1 <- if (isTRUE(input$plot_cm)) { iv_cm <- shinyvalidate::InputValidator$new() conmed_var <- input$conmed_var iv_cm$add_rule("conmed_var", shinyvalidate::sv_required()) @@ -403,7 +406,7 @@ srv_g_heatmap_bygrade <- function(id, validate(need(iv_cm$is_valid(), "Misspecification error: please observe red flags in the encodings.")) teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code(data)), + teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = bquote({ conmed_data <- ADCM %>% filter(!!sym(.(conmed_var)) %in% .(input$conmed_level)) @@ -447,6 +450,13 @@ srv_g_heatmap_bygrade <- function(id, plot_r <- reactive(output_q()[["plot"]]) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", title = paste("R code for", label), diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index 8d346c52..2a5032aa 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -394,7 +394,10 @@ ui_g_patient_profile <- function(id, ...) { value = a$x_limit ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code"), + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ), pre_output = a$pre_output, post_output = a$post_output ) @@ -632,9 +635,10 @@ srv_g_patient_profile <- function(id, lb_dataname ) input_select <- purrr::map_lgl(datanames, is.na) + select_plot <- purrr::map2_lgl( input_select, possible_plot, - ~ if (!.x) { + ~ if (!.x && paste("select", .y, sep = "_") %in% names(input)) { input[[paste("select", .y, sep = "_")]] } else { FALSE @@ -650,7 +654,7 @@ srv_g_patient_profile <- function(id, empty_lb <- FALSE q1 <- teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code(data)), + teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = bquote({ ADSL <- ADSL %>% # nolint group_by(.data$USUBJID) @@ -1068,6 +1072,13 @@ srv_g_patient_profile <- function(id, width = plot_width ) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", title = paste("R code for", label), diff --git a/R/tm_g_spiderplot.R b/R/tm_g_spiderplot.R index 3c83d0a1..51f01806 100644 --- a/R/tm_g_spiderplot.R +++ b/R/tm_g_spiderplot.R @@ -209,7 +209,10 @@ ui_g_spider <- function(id, ...) { value = a$href_line ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code"), + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ), pre_output = a$pre_output, post_output = a$post_output ) @@ -271,7 +274,7 @@ srv_g_spider <- function(id, data, filter_panel_api, reporter, dataname, label, # merge q1 <- teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code(data)), + teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = bquote({ ADSL <- ADSL[, .(adsl_vars)] %>% as.data.frame() # nolint ADTR <- .(as.name(dataname))[, .(adtr_vars)] %>% as.data.frame() # nolint @@ -379,6 +382,13 @@ srv_g_spider <- function(id, data, filter_panel_api, reporter, dataname, label, width = plot_width ) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", title = paste("R code for", label), diff --git a/R/tm_g_swimlane.R b/R/tm_g_swimlane.R index f7bcba12..f7a28098 100644 --- a/R/tm_g_swimlane.R +++ b/R/tm_g_swimlane.R @@ -243,7 +243,10 @@ ui_g_swimlane <- function(id, ...) { value = paste(a$vref_line, collapse = ", ") ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code"), + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ), pre_output = a$pre_output, post_output = a$post_output ) @@ -316,7 +319,7 @@ srv_g_swimlane <- function(id, ADSL <- data[["ADSL"]]() # nolint - q1 <- teal.code::new_qenv(tdata2env(data), code = get_code(data)) + q1 <- teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) # VARIABLE GETTERS # lookup bar variables @@ -513,6 +516,13 @@ srv_g_swimlane <- function(id, width = plot_width ) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + teal.widgets::verbatim_popup_srv( id = "rcode", title = paste("R code for", label), diff --git a/R/tm_g_waterfall.R b/R/tm_g_waterfall.R index c4f77695..863cff0d 100644 --- a/R/tm_g_waterfall.R +++ b/R/tm_g_waterfall.R @@ -265,7 +265,10 @@ ui_g_waterfall <- function(id, ...) { value = a$gap_point_val ) ), - forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code"), + forms = tagList( + teal.widgets::verbatim_popup_ui(ns("warning"), "Show Warnings"), + teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code") + ), pre_output = a$pre_output, post_output = a$post_output ) @@ -388,7 +391,7 @@ srv_g_waterfall <- function(id, # write variables to qenv q1 <- teal.code::eval_code( - teal.code::new_qenv(tdata2env(data), code = get_code(data)), + teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)), code = bquote({ bar_var <- .(bar_var) bar_color_var <- .(bar_color_var) @@ -521,6 +524,13 @@ srv_g_waterfall <- function(id, width = plot_width ) + teal.widgets::verbatim_popup_srv( + id = "warning", + verbatim_content = reactive(teal.code::get_warnings(output_q())), + title = "Warning", + disabled = reactive(is.null(teal.code::get_warnings(output_q()))) + ) + # Show R Code teal.widgets::verbatim_popup_srv( id = "rcode",