Skip to content

Commit

Permalink
tdata to teal_data - tm_a_regression (#609)
Browse files Browse the repository at this point in the history
**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)
```
  • Loading branch information
kartikeyakirar authored Nov 23, 2023
1 parent 6e99d25 commit 166b9a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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({
Expand All @@ -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))
})

Expand Down

0 comments on commit 166b9a2

Please sign in to comment.