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

[Bug]: var_labels not work for estimate_odds_ratio #1315

Closed
3 tasks done
lchensigma opened this issue Sep 28, 2024 · 0 comments · Fixed by #1317
Closed
3 tasks done

[Bug]: var_labels not work for estimate_odds_ratio #1315

lchensigma opened this issue Sep 28, 2024 · 0 comments · Fixed by #1317
Assignees
Labels
bug Something isn't working

Comments

@lchensigma
Copy link

lchensigma commented Sep 28, 2024

What happened?

A bug happened!

nex <- 800 # Number of example rows
dta <- data.frame(
  "is_event" = sample(c(TRUE, FALSE), nex, TRUE),
  "TRT01P" = sample(c("A", "B"), nex, TRUE),
  "f1" = sample(c("a1", "a2"), nex, TRUE),
  "f2" = sample(c("x", "y", "z"), nex, TRUE),
  "BLSTRA" = factor(sample(c("C", "D"), nex, TRUE)),
  stringsAsFactors = TRUE
)

lyt_proportion <- basic_table( ) %>% 
  split_cols_by(var = "TRT01P", ref_group = "A") %>%
  estimate_proportion(
    vars = "is_event",
    table_names = "prop",
    .labels = c("Response Rate n (%)", "95% CI (Clopper-Pearson)[1]"),
    method = "clopper-pearson"
  ) |>
estimate_proportion_diff(
    var_labels = "Stratified Analysis [2]",
    vars = "is_event",
    show_labels = "visible",
    method = "cmh",
    variables = list(strata = "BLSTRA"),
    table_names = "est_prop_diff_strat"
  ) %>%
  estimate_odds_ratio(
    vars = "is_event",
    var_labels = "Stratified OR Analysis [2]",
    show_labels = "visible",
    table_names = "est_or_strata",
    variables = list(arm = "TRT01P", strata = "BLSTRA"),
    .labels = "Stratified Odds Ratio (95% CI)",
    .indent_mods = 1L
  ) 



result_proportion <- build_table(
  lyt = lyt_proportion,
  df = dta
)

result_proportion %>% tt_to_flextable()

sessionInfo()

> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] optimx_2023-10.21   emmeans_1.10.4      forestploter_1.1.2  tern.mmrm_0.3.1     scda_0.1.6         
 [6] tern_0.9.5          haven_2.5.4         rtables_0.6.9       magrittr_2.0.3      formatters_0.5.9   
[11] rstan_2.32.6        StanHeaders_2.32.10 tidybayes_3.0.7     bayesplot_1.11.1    brms_2.21.0        
[16] Rcpp_1.0.13         dreamer_3.1.0       DoseFinding_1.2-1   labelled_2.13.0     gt_0.11.0          
[21] flextable_0.9.6     broom_1.0.6         readxl_1.4.3        boxr_0.3.6          pander_0.6.5       
[26] patchwork_1.3.0     ggprism_1.0.5       gtsummary_2.0.2     ggthemes_5.1.0      plyr_1.8.9         
[31] knitr_1.48          lubridate_1.9.3     forcats_1.0.0       stringr_1.5.1       dplyr_1.1.4        
[36] purrr_1.0.2         readr_2.1.5         tidyr_1.3.1         tibble_3.2.1        ggplot2_3.5.1      
[41] tidyverse_2.0.0    

loaded via a namespace (and not attached):
  [1] tensorA_0.36.2.1        rstudioapi_0.16.0       jsonlite_1.8.8          TH.data_1.1-2          
  [5] estimability_1.5.1      nloptr_2.1.1            farver_2.1.2            rmarkdown_2.28         
  [9] ragg_1.3.3              vctrs_0.6.5             askpass_1.2.0           htmltools_0.5.8.1      
 [13] distributional_0.5.0    curl_5.2.2              cellranger_1.1.0        pracma_2.4.4           
 [17] parallelly_1.38.0       sandwich_3.1-1          zoo_1.8-12              uuid_1.2-1             
 [21] lifecycle_1.0.4         pkgconfig_2.0.3         Matrix_1.6-5            R6_2.5.1               
 [25] fastmap_1.2.0           rbibutils_2.2.16        numDeriv_2016.8-1.1     digest_0.6.37          
 [29] colorspace_2.1-1        rprojroot_2.0.4         textshaping_0.4.0       fansi_1.0.6            
 [33] timechange_0.3.0        abind_1.4-8             compiler_4.3.1          here_1.0.1             
 [37] fontquiver_0.2.1        withr_3.0.1             backports_1.5.0         inline_0.3.19          
 [41] QuickJSR_1.3.1          pkgbuild_1.4.4          MASS_7.3-60.0.1         openssl_2.2.1          
 [45] equatags_0.2.1          loo_2.8.0               tools_4.3.1             zip_2.3.1              
 [49] glue_1.7.0              mmrm_0.3.12             nlme_3.1-166            grid_4.3.1             
 [53] checkmate_2.3.2         generics_0.1.3          xslt_1.4.5              gtable_0.3.5           
 [57] tzdb_0.4.0              data.table_1.16.0       hms_1.1.3               katex_1.4.1            
 [61] xml2_1.3.6              utf8_1.2.4              pillar_1.9.0            ggdist_3.3.2           
 [65] posterior_1.6.0         splines_4.3.1           lattice_0.22-6          survival_3.7-0         
 [69] tidyselect_1.2.1        fontLiberation_0.1.0    fontBitstreamVera_0.1.1 arrayhelpers_1.1-0     
 [73] gridExtra_2.3           V8_5.0.0                stats4_4.3.1            xfun_0.47              
 [77] bridgesampling_1.1-2    matrixStats_1.4.1       stringi_1.8.4           yaml_2.3.10            
 [81] evaluate_1.0.0          codetools_0.2-19        officer_0.6.6           gdtools_0.4.0          
 [85] cli_3.6.3               RcppParallel_5.1.9      xtable_1.8-4            systemfonts_1.1.0      
 [89] Rdpack_2.6.1            munsell_0.5.1           coda_0.19-4.1           svUnit_1.0.6           
 [93] parallel_4.3.1          rstantools_2.4.0        Brobdingnag_1.2-9       mvtnorm_1.3-1          
 [97] scales_1.3.0            rlang_1.1.4             cowplot_1.1.3           multcomp_1.4-26

Relevant log output

Stratified Analysis [2]



Difference in Response rate (%)


5.5

95% CI (CMH, without correction)


(-1.4, 12.4)

p-value (Cochran-Mantel-Haenszel Test)


0.1183

is_event



Stratified Odds Ratio (95% CI)


1.25 (0.95 - 1.65)

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@lchensigma lchensigma added the bug Something isn't working label Sep 28, 2024
@ayogasekaram ayogasekaram self-assigned this Sep 30, 2024
ayogasekaram added a commit that referenced this issue Sep 30, 2024
closes #1315

---------

Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants