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 missing counts may not respect order variable assignments #45

Open
mstackhouse opened this issue Mar 28, 2022 · 0 comments
Open

Comments

@mstackhouse
Copy link
Contributor

Prerequisites

For more information, see the CONTRIBUTING guide.

Description

This might be an unlikely case, but it's an assumed capability. Tplyr allows you to set multiple missing count variables. If multiple values are assigned, order layer values may not be assigned properly in a nested layer.

This might be a design flaw in set_missing_count(). Only one sort value is assigned, but multiple 'missing' placeholders are allowed.

Steps to Reproduce (Bug Report Only)

adsl <- haven::read_xpt(url("https://github.com/phuse-org/TestDataFactory/raw/main/Updated/TDF_ADaM/adsl.xpt"))

t <- tplyr_table(adsl, TRT01A) %>%
  add_layer(
    group_count(vars(EOSSTT, DCDECOD)) %>%
      set_order_count_method(c("byfactor", "bycount")) %>% 
      add_total_row(f_str('xx', n), count_missing=FALSE) %>% 
      set_missing_count(f_str("xxx", n), sort_value=Inf, denom_ignore=TRUE, Missing = NA, Blank = '')
  ) 

t %>% 
  build() %>% 
  arrange(ord_layer_1, desc(ord_layer_2)) 

# A tibble: 14 × 8
   row_label1   row_label2                       var1_Placebo  `var1_Xanomeline High Dose` `var1_Xanomeline Low Dose` ord_layer_index ord_layer_1 ord_layer_2
   <chr>        <chr>                            <chr>         <chr>                       <chr>                                <int>       <dbl>       <dbl>
 1 Blank        "Blank"                          " 0 (  0.0%)" " 0 (  0.0%)"               " 0 (  0.0%)"                            1           1         Inf
 2 COMPLETED    "COMPLETED"                      "58 ( 67.4%)" "27 ( 32.1%)"               "25 ( 29.8%)"                            1           2         Inf
 3 COMPLETED    "   COMPLETED"                   "58 ( 67.4%)" "27 ( 32.1%)"               "25 ( 29.8%)"                            1           2          58
 4 DISCONTINUED "DISCONTINUED"                   "28 ( 32.6%)" "57 ( 67.9%)"               "59 ( 70.2%)"                            1           3         Inf
 5 DISCONTINUED "   WITHDRAWAL BY SUBJECT"       " 9 ( 10.5%)" " 8 (  9.5%)"               "10 ( 11.9%)"                            1           3           9
 6 DISCONTINUED "   ADVERSE EVENT"               " 8 (  9.3%)" "40 ( 47.6%)"               "44 ( 52.4%)"                            1           3           8
 7 DISCONTINUED "   LACK OF EFFICACY"            " 3 (  3.5%)" " 1 (  1.2%)"               " 0 (  0.0%)"                            1           3           3
 8 DISCONTINUED "   DEATH"                       " 2 (  2.3%)" " 0 (  0.0%)"               " 1 (  1.2%)"                            1           3           2
 9 DISCONTINUED "   PROTOCOL VIOLATION"          " 2 (  2.3%)" " 3 (  3.6%)"               " 1 (  1.2%)"                            1           3           2
10 DISCONTINUED "   STUDY TERMINATED BY SPONSOR" " 2 (  2.3%)" " 3 (  3.6%)"               " 2 (  2.4%)"                            1           3           2
11 DISCONTINUED "   LOST TO FOLLOW-UP"           " 1 (  1.2%)" " 0 (  0.0%)"               " 1 (  1.2%)"                            1           3           1
12 DISCONTINUED "   PHYSICIAN DECISION"          " 1 (  1.2%)" " 2 (  2.4%)"               " 0 (  0.0%)"                            1           3           1
13 Missing      "Missing"                        " 0 (  0.0%)" " 0 (  0.0%)"               " 0 (  0.0%)"                            1           4         Inf
14 Total        "Total"                          "86 (100.0%)" "84 (100.0%)"               "84 (100.0%)"                            1           5         Inf

Expected behavior: [What you expected to happen]

The 'Blank' row should be arranged with 'Missing' and 'Total down below.

Actual behavior: [What actually happened]

'Blank' actually gets the value of 1 for ord_layer_1 which is unexpected.

Note: This was found on branch gh_issue_32 which is branched off of devel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant