Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce decorators for tm_a_gee #1259

Closed

Conversation

llrs-roche
Copy link

Part of insightsengineering/teal#1371

Working example (WIP)
App

Copy link
Contributor

github-actions bot commented Nov 27, 2024

✅ All contributors have signed the CLA
Posted by the CLA Assistant Lite bot.

@m7pr
Copy link
Contributor

m7pr commented Nov 27, 2024

@llrs-roche you need to reply with

I have read the CLA Document and I hereby sign the CLA

@m7pr
Copy link
Contributor

m7pr commented Nov 27, 2024

@llrs-roche please add sprint

R/tm_a_gee.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
@m7pr
Copy link
Contributor

m7pr commented Nov 27, 2024

@llrs-roche you are missing

      ui_decorate_teal_data(ns("decorator"), decorators = subset_decorators("table", a$decorators)),

@m7pr
Copy link
Contributor

m7pr commented Nov 27, 2024

Just go by another PR and copy paste all the new lines
https://github.com/insightsengineering/teal.modules.clinical/pull/1257/files

@llrs-roche
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

llrs-roche and others added 5 commits November 27, 2024 10:42
Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com>
Signed-off-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com>
@m7pr m7pr self-assigned this Nov 27, 2024
man/tm_a_gee.Rd Outdated Show resolved Hide resolved
@m7pr
Copy link
Contributor

m7pr commented Nov 27, 2024

@llrs-roche I left 2 more comments. Please provide a working app in the opening of this PR. Once you are done with the working example, please make this ready for the review and I will review.

@m7pr
Copy link
Contributor

m7pr commented Nov 27, 2024

I am trying to create a working example for this one

devtools::load_all("../teal.reporter")
devtools::load_all("../teal")
devtools::load_all(".")

insert_rrow_decorator <- function(default_caption = "I am a good new row", .var_to_replace = "table") {
  teal_transform_module(
    label = "New row",
    ui = function(id) shiny::textInput(shiny::NS(id, "new_row"), "New row", value = default_caption),
    server = make_teal_transform_server(
      substitute({
        .var_to_replace <- rtables::insert_rrow(.var_to_replace, rtables::rrow(new_row))
      }, env = list(.var_to_replace = as.name(.var_to_replace)))
    )
  )
}

library(dplyr)

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADQS <- tmc_ex_adqs %>%
    filter(ABLFL != "Y" & ABLFL2 != "Y") %>%
    mutate(
      AVISIT = as.factor(AVISIT),
      AVISITN = rank(AVISITN) %>%
        as.factor() %>%
        as.numeric() %>%
        as.factor(),
      AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint.
    ) %>%
    droplevels()
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_a_gee(
      label = "GEE",
      dataname = "ADQS",
      aval_var = choices_selected("AVALBIN", fixed = TRUE),
      id_var = choices_selected(c("USUBJID", "SUBJID"), "USUBJID"),
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"),
      paramcd = choices_selected(
        choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"),
        selected = "FKSI-FWB"
      ),
      cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL),
      decorators = list(insert_rrow_decorator("Hello world", "table"))
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

R/tm_a_gee.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
R/tm_a_gee.R Outdated Show resolved Hide resolved
@m7pr
Copy link
Contributor

m7pr commented Nov 27, 2024

Hey @llrs-roche I've got no idea what's wrong on this branch. I spent 45 minutes trying to improve, but lastly decided to do it from scratch on another PR where it worked.

Please close this one, review the one that I provided #1262
and let me know if you found out what was broken in here

@llrs-roche
Copy link
Author

On one side, I'm happy it was not just me but on the other side, I'm not sure how I broke it so much. Closing it

@llrs-roche llrs-roche closed this Nov 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2024
),
forms = tagList(
teal.widgets::verbatim_popup_ui(ns("rcode"), button_label = "Show R code")
),
pre_output = a$pre_output,
post_output = a$post_output
)
a
Copy link
Contributor

Choose a reason for hiding this comment

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

@llrs-roche this is the issue that broke this branch

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.

2 participants