From 166b9a26bc5bc5d0edfb9b87f529876f77d90604 Mon Sep 17 00:00:00 2001 From: kartikeya kirar Date: Thu, 23 Nov 2023 15:07:24 +0530 Subject: [PATCH] `tdata` to `teal_data` - `tm_a_regression` (#609) **Example App** ``` data <- teal_data() data <- within(data, { library(nestcolor) ADSL <- teal.modules.general::rADSL }) datanames <- c("ADSL") datanames(data) <- datanames join_keys(data) <- default_cdisc_join_keys[datanames] app <- teal::init( data = data, modules = teal::modules( teal.modules.general::tm_a_regression( label = "Regression", response = teal.transform::data_extract_spec( dataname = "ADSL", select = teal.transform::select_spec( label = "Select variable:", choices = "BMRKR1", selected = "BMRKR1", multiple = FALSE, fixed = TRUE ) ), regressor = teal.transform::data_extract_spec( dataname = "ADSL", select = teal.transform::select_spec( label = "Select variables:", choices = teal.transform::variable_choices(data[["ADSL"]], c("AGE", "SEX", "RACE")), selected = "AGE", multiple = TRUE, fixed = FALSE ) ), ggplot2_args = teal.widgets::ggplot2_args( labs = list(subtitle = "Plot generated by Regression Module") ) ) ) ) shinyApp(app$ui, app$server) ``` --- R/tm_a_regression.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/tm_a_regression.R b/R/tm_a_regression.R index 775fbbca2..9b7ed22cf 100644 --- a/R/tm_a_regression.R +++ b/R/tm_a_regression.R @@ -246,7 +246,8 @@ srv_a_regression <- function(id, default_outlier_label) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") - checkmate::assert_class(data, "tdata") + checkmate::assert_class(data, "reactive") + checkmate::assert_class(isolate(data()), "teal_data") moduleServer(id, function(input, output, session) { rule_rvr1 <- function(value) { if (isTRUE(input$plot_type == "Response vs Regressor")) { @@ -294,8 +295,7 @@ srv_a_regression <- function(id, anl_merged_input <- teal.transform::merge_expression_srv( selector_list = selector_list, - datasets = data, - join_keys = teal.data::join_keys(data) + datasets = data ) regression_var <- reactive({ @@ -309,7 +309,7 @@ srv_a_regression <- function(id, anl_merged_q <- reactive({ req(anl_merged_input()) - teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>% + data() %>% teal.code::eval_code(as.expression(anl_merged_input()$expr)) })