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

multiple tables row binds together #962

Closed
Tracked by #952
Melkiades opened this issue Nov 21, 2024 · 1 comment
Closed
Tracked by #952

multiple tables row binds together #962

Melkiades opened this issue Nov 21, 2024 · 1 comment
Labels
ARD exploration explores ways that might be source of errors or features sme

Comments

@Melkiades
Copy link
Contributor

No description provided.

@Melkiades Melkiades added exploration explores ways that might be source of errors or features sme ARD labels Nov 21, 2024
@Melkiades
Copy link
Contributor Author

Melkiades commented Jan 27, 2025

It seems to work:

library(rtables)
#> Loading required package: formatters
#> 
#> Attaching package: 'formatters'
#> The following object is masked from 'package:base':
#> 
#>     %||%
#> Loading required package: magrittr
#> 
#> Attaching package: 'rtables'
#> The following object is masked from 'package:utils':
#> 
#>     str
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union


combodf <- tribble(
  ~valname, ~label, ~levelcombo, ~exargs,
  "A_B", "Arms A+B", c("A: Drug X", "B: Placebo"), list(),
  "A_C", "Arms A+C", c("A: Drug X", "C: Combination"), list()
)

l1 <- basic_table(show_colcounts = TRUE) %>%
  split_cols_by("ARM", split_fun = add_combo_levels(combodf)) %>%
  analyze("AGE")

tab1 <- build_table(l1, DM)

l2 <- basic_table(show_colcounts = TRUE) %>%
  split_cols_by("ARM", split_fun = add_combo_levels(combodf)) %>%
  analyze("SEX")

tab2 <- build_table(l2, DM)

tab3 <- rbind(tab1, tab2)

as_result_df(tab3, make_ard = TRUE)
#>    group1   group1_level         variable   variable_level   variable_label
#> 1     ARM      A: Drug X             Mean             Mean             Mean
#> 2     ARM      A: Drug X                F                F                F
#> 3     ARM      A: Drug X                M                M                M
#> 4     ARM      A: Drug X                U                U                U
#> 5     ARM      A: Drug X UNDIFFERENTIATED UNDIFFERENTIATED UNDIFFERENTIATED
#> 6     ARM     B: Placebo             Mean             Mean             Mean
#> 7     ARM     B: Placebo                F                F                F
#> 8     ARM     B: Placebo                M                M                M
#> 9     ARM     B: Placebo                U                U                U
#> 10    ARM     B: Placebo UNDIFFERENTIATED UNDIFFERENTIATED UNDIFFERENTIATED
#> 11    ARM C: Combination             Mean             Mean             Mean
#> 12    ARM C: Combination                F                F                F
#> 13    ARM C: Combination                M                M                M
#> 14    ARM C: Combination                U                U                U
#> 15    ARM C: Combination UNDIFFERENTIATED UNDIFFERENTIATED UNDIFFERENTIATED
#> 16    ARM       Arms A+B             Mean             Mean             Mean
#> 17    ARM       Arms A+B                F                F                F
#> 18    ARM       Arms A+B                M                M                M
#> 19    ARM       Arms A+B                U                U                U
#> 20    ARM       Arms A+B UNDIFFERENTIATED UNDIFFERENTIATED UNDIFFERENTIATED
#> 21    ARM       Arms A+C             Mean             Mean             Mean
#> 22    ARM       Arms A+C                F                F                F
#> 23    ARM       Arms A+C                M                M                M
#> 24    ARM       Arms A+C                U                U                U
#> 25    ARM       Arms A+C UNDIFFERENTIATED UNDIFFERENTIATED UNDIFFERENTIATED
#>    stat_name      stat
#> 1       mean  34.90909
#> 2          n  70.00000
#> 3          n  51.00000
#> 4          n   0.00000
#> 5          n   0.00000
#> 6       mean  33.01887
#> 7          n  56.00000
#> 8          n  50.00000
#> 9          n   0.00000
#> 10         n   0.00000
#> 11      mean  34.56589
#> 12         n  61.00000
#> 13         n  68.00000
#> 14         n   0.00000
#> 15         n   0.00000
#> 16      mean  34.02643
#> 17         n 126.00000
#> 18         n 101.00000
#> 19         n   0.00000
#> 20         n   0.00000
#> 21      mean  34.73200
#> 22         n 131.00000
#> 23         n 119.00000
#> 24         n   0.00000
#> 25         n   0.00000

Created on 2025-01-27 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARD exploration explores ways that might be source of errors or features sme
Projects
None yet
Development

No branches or pull requests

1 participant