Skip to content

Conversation

@averissimo
Copy link
Contributor

Part of #863

Working Example
pkgload::load_all("../teal")
pkgload::load_all("../teal.modules.general")

footnote_dec <- teal_transform_module(
  label = "Footnote",
  ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = "I am a good decorator"),
  server = function(id, data) {
    moduleServer(id, function(input, output, session) {
      logger::log_info("🟢 Footnote called to action!", namespace = "teal.modules.general")
      reactive(
        within(
          data(),
          {
            footnote_str <- footnote
            plot <- plot + ggplot2::labs(caption = footnote_str)
          },
          footnote = input$footnote
        )
      )
    })
  }
)

table_dup_dec <- teal_transform_module(
  server = make_teal_transform_server(
    expression(
      logger::log_info("🔴 Table dup being called to action!", namespace = "teal.modules.general"),
      summary_table <- rbind(summary_table, summary_table),
      if (exists("test_table")) test_table <- rbind(test_table, test_table, test_table) 
    )
  )
)

# CDISC data example
data <- teal_data()
data <- within(data, {
  ADSL <- rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

vars1 <- choices_selected(
  variable_choices(data[["ADSL"]], c("ARM", "COUNTRY", "SEX")),
  selected = NULL
)

app <- init(
  data = data,
  modules = modules(
    tm_g_distribution(
      decorators = list(footnote_dec, table_dup_dec),
      dist_var = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")),
          selected = "BMRKR1",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      strata_var = data_extract_spec(
        dataname = "ADSL",
        filter = filter_spec(
          vars = vars1,
          multiple = TRUE
        )
      ),
      group_var = data_extract_spec(
        dataname = "ADSL",
        filter = filter_spec(
          vars = vars1,
          multiple = TRUE
        )
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

@gogonzo gogonzo mentioned this pull request Nov 19, 2024
15 tasks
@averissimo averissimo marked this pull request as ready for review November 20, 2024 11:44
@m7pr m7pr self-requested a review November 20, 2024 13:30
@m7pr m7pr self-assigned this Nov 20, 2024
@m7pr
Copy link
Contributor

m7pr commented Nov 20, 2024

Hi, when I open, QQplot panel I don't see the plot and I see such issue

image

this is because the Theoretical Distribution is not selected. Maybe we can extend the module so it picks one distribution by default?

@m7pr
Copy link
Contributor

m7pr commented Nov 20, 2024

There is also issue with Show R Code

image
Error in decorated_output_q(): could not find function "decorated_output_q"

Copy link
Contributor

@m7pr m7pr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting some small changes!

@averissimo averissimo requested a review from m7pr November 21, 2024 14:20
Copy link
Contributor

@m7pr m7pr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please unify decorators = NULL if other PRs

@averissimo averissimo merged commit 006b374 into 1187_decorate_output@main Nov 21, 2024
1 check passed
@averissimo averissimo deleted the tm_g_distribution@1187_decorate_output@main branch November 21, 2024 15:13
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants