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

[Feature Request]: <Indention not aligned in surv_timepoint> #936

Closed
3 tasks done
Teninq opened this issue May 25, 2023 · 0 comments · Fixed by #938 or #945
Closed
3 tasks done

[Feature Request]: <Indention not aligned in surv_timepoint> #936

Teninq opened this issue May 25, 2023 · 0 comments · Fixed by #938 or #945
Assignees
Labels
bug Something isn't working sme

Comments

@Teninq
Copy link

Teninq commented May 25, 2023

Feature description

We can two analysis in the function surv_timepoint: surv and surv_diff. And we can also choose both in the method parameter.

library(tern)
library(scda)
library(dplyr)

adsl <- synthetic_cdisc_dataset("latest", "adsl")
adtte <- synthetic_cdisc_dataset("latest", "adtte")

# Ensure that character variables are converted to factors and empty strings and NAs are explicit missing levels.
adsl <- df_explicit_na(adsl)
adtte <- df_explicit_na(adtte)

adtte_f <- adtte %>%
  dplyr::filter(PARAMCD == "OS") %>%
  dplyr::mutate(
    AVAL = day2month(AVAL),
    is_event = CNSR == 0,
    is_not_event = CNSR == 1,
    EVNTDESC = factor(EVNTDESC)
  )

lyt <- basic_table(show_colcounts = TRUE) %>%
  split_cols_by(
    var = "ARM", ref_group = "A: Drug X"
  ) %>%
  summarize_vars(
    vars = "is_event",
    .stats = "count_fraction",
    .labels = c(count_fraction = "Patients with event (%)")
  ) %>% 
  summarize_vars(
    vars = "is_not_event",
    .stats = "count_fraction",
    .labels = c(count_fraction = "Patients without event (%)"),
    nested = FALSE,
    show_labels = "hidden"
  ) %>%
  surv_timepoint(
    vars = "AVAL",
    var_labels = "Months",
    time_point = c(6, 12),
    is_event = "is_event",
    method = "surv",
    control = control_surv_timepoint()
  ) %>% 
  surv_timepoint(
    vars = "AVAL",
    var_labels = "Months",
    time_point = c(6, 12),
    is_event = "is_event",
    method = "surv_diff",
    control = control_surv_timepoint()
  ) %>% 
  surv_timepoint(
    vars = "AVAL",
    var_labels = "Months",
    time_point = c(6, 12),
    is_event = "is_event",
    method = "both",
    control = control_surv_timepoint()
  )

result <- build_table(lyt, df = adtte_f, alt_counts_df = adsl)
result

The layout looks like below, When I run the surv_timepoint function with each single method, it works well with correct indention. But failed to align indention when we choose both.

                                    A: Drug X        B: Placebo      C: Combination 
                                     (N=134)          (N=134)           (N=132)     
————————————————————————————————————————————————————————————————————————————————————
Patients with event (%)              79 (59%)        87 (64.9%)       116 (87.9%)   
Patients without event (%)           55 (41%)        47 (35.1%)        16 (12.1%)   
6 Months                                                                            
  Patients remaining at risk           106              112                92       
  Event Free Rate (%)                 83.83            89.16             73.40      
  95% CI                          (77.49, 90.17)   (83.80, 94.53)    (65.72, 81.07) 
12 Months                                                                           
  Patients remaining at risk            92               83                56       
  Event Free Rate (%)                 78.03            70.32             46.39      
  95% CI                          (70.82, 85.24)   (62.27, 78.37)    (37.59, 55.18) 
6 Months                                                                            
  Difference in Event Free Rate                         5.33             -10.43     
  95% CI                                           (-2.97, 13.64)   (-20.38, -0.48) 
  p-value (Z-test)                                     0.2080            0.0399     
12 Months                                                                           
  Difference in Event Free Rate                        -7.71             -31.64     
  95% CI                                           (-18.51, 3.10)   (-43.01, -20.26)
  p-value (Z-test)                                     0.1622           <0.0001     
6 Months                                                                            
  Patients remaining at risk           106              112                92       
  Event Free Rate (%)                 83.83            89.16             73.40      
  95% CI                          (77.49, 90.17)   (83.80, 94.53)    (65.72, 81.07) 
Difference in Event Free Rate                           5.33             -10.43     
95% CI                                             (-2.97, 13.64)   (-20.38, -0.48) 
p-value (Z-test)                                       0.2080            0.0399     
12 Months                                                                           
  Patients remaining at risk            92               83                56       
  Event Free Rate (%)                 78.03            70.32             46.39      
  95% CI                          (70.82, 85.24)   (62.27, 78.37)    (37.59, 55.18) 
Difference in Event Free Rate                          -7.71             -31.64     
95% CI                                             (-18.51, 3.10)   (-43.01, -20.26)
p-value (Z-test)                                       0.1622           <0.0001 

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.
@Melkiades Melkiades self-assigned this May 25, 2023
@Melkiades Melkiades added bug Something isn't working sme and removed enhancement labels May 25, 2023
Melkiades added a commit that referenced this issue Jun 6, 2023
Fixes #931 and #936

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
@Melkiades Melkiades reopened this Jun 6, 2023
@Melkiades Melkiades linked a pull request Jun 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sme
Projects
None yet
2 participants