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

Update tm_g_distribution.R #766

Merged
merged 5 commits into from
Sep 12, 2024
Merged

Conversation

saerobson
Copy link
Contributor

@saerobson saerobson commented Aug 1, 2024

I have made a direct PR as it was recommended for such small updates.
Fix distribution default parameters when multiple data_extract_spec's are specified.
Documentation states that multiple data_extract_spec’s can be specified so this solution makes this work.

Problem:
https://github.com/user-attachments/assets/08e0a0b6-3e26-4d2b-97c7-82c9feaa0ad0

Solution:
https://github.com/user-attachments/assets/b9cd2122-4cb6-4913-90cb-bb67c185693e

Fix distribution default parameters when multiple data_extracts are specified

Signed-off-by: saerobson <[email protected]>
Copy link
Contributor

github-actions bot commented Aug 1, 2024

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

@saerobson
Copy link
Contributor Author

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

@donyunardi
Copy link
Contributor

@saerobson
Thanks for providing a video on the problem.
Can I also ask for the code that you use so I can reproduce the issue?

@sarah-robson
Copy link

Please find the code below to create the broken app video.

# library
library(shiny)
library(teal)
library(teal.widgets)
library(teal.modules.general)
library(teal.logger)

# global variables
ggplot_themes <- c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void")
interactive <- NULL

# CDISC data example
data <- teal_data()
data <- within(data, {
  ADSL <- rADSL
  ADVS <- rADVS
})
datanames(data) <- c("ADSL", "ADVS")
join_keys(data) <- default_cdisc_join_keys[datanames(data)]

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

# data_extract_specs
dist_var_adsl = data_extract_spec(
  dataname = "ADSL",
  select = select_spec(
    choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")),
    selected = "BMRKR1",
    multiple = FALSE,
    fixed = FALSE
  )
)

dist_var_advs = data_extract_spec(
  dataname = "ADVS",
  select = select_spec(
    choices = variable_choices(data[["ADVS"]], c("AVAL")),
    selected = "AVAL",
    multiple = FALSE,
    fixed = FALSE
  )
)


# app
app <- init(
  data = data,
  modules = modules(
    tm_g_distribution(
      dist_var = list(dist_var_adsl,
                      dist_var_advs
      ),
      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
        )
      ),
      ggplot2_args = ggplot2_args(
        labs = list(subtitle = "Plot generated by Distribution Module")
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

@Polkas
Copy link
Contributor

Polkas commented Sep 5, 2024

@gogonzo Please help us with the review:)

@gogonzo gogonzo self-assigned this Sep 9, 2024
@gogonzo gogonzo added the core label Sep 9, 2024
@gogonzo gogonzo self-requested a review September 9, 2024 05:40
R/tm_g_distribution.R Outdated Show resolved Hide resolved
Co-authored-by: Dawid Kałędkowski <[email protected]>
Signed-off-by: saerobson <[email protected]>
Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@gogonzo
Copy link
Contributor

gogonzo commented Sep 12, 2024

Thanks @saerobson

@gogonzo gogonzo merged commit de466ac into insightsengineering:main Sep 12, 2024
25 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 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.

5 participants