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

Fixes to various row_labels situations with tests. #700

Merged
merged 3 commits into from
Aug 11, 2023

Conversation

gmbecker
Copy link
Collaborator

@gmbecker gmbecker commented Jul 27, 2023

Close #698.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 27, 2023

badge

Code Coverage Summary

Filename                     Stmts    Miss  Cover    Missing
-------------------------  -------  ------  -------  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
R/00tabletrees.R               662      46  93.05%   24, 94, 96, 371, 447-448, 451, 590, 681, 763-764, 854, 856-857, 880-881, 901, 1080-1083, 1214, 1298-1299, 1358-1361, 1394-1395, 1401-1406, 1449, 1455, 1544, 1636, 1647, 1649-1650, 1653-1654, 1682, 1708-1709
R/as_html.R                     88       7  92.05%   7-12, 68
R/colby_constructors.R         489      17  96.52%   63, 106-107, 155-156, 202-203, 328, 341, 1063, 1138, 1281, 1317, 1336, 1356, 1375, 1519
R/compare_rtables.R             78      11  85.90%   95-96, 99-100, 113-114, 131, 150-151, 181, 185
R/format_rcell.R                12       0  100.00%
R/indent.R                      13       2  84.62%   39-40
R/index_footnotes.R             52       0  100.00%
R/make_split_fun.R              97      15  84.54%   22-25, 48-49, 51-52, 103, 106, 252, 254-255, 259-260, 276, 366
R/make_subset_expr.R           106      12  88.68%   26-35, 93-98, 131, 197, 208, 215
R/simple_analysis.R              5       1  80.00%   48
R/split_funs.R                 424      54  87.26%   131, 135, 140-145, 149, 159-161, 195-196, 318-321, 337-342, 412, 452, 466-467, 481, 537, 546-547, 549, 561, 601, 621, 780, 787, 812-813, 821-822, 824-825, 983-984, 995-998, 1061-1062, 1118-1119
R/summary.R                    187      20  89.30%   40, 84, 188, 195, 260-263, 273-274, 293-294, 399, 453-457, 485, 513
R/tree_accessors.R             798      74  90.73%   93, 210, 223, 240, 271, 281, 293, 385, 407-408, 662-666, 774, 788, 805, 846, 900-901, 933, 959, 991-995, 1042, 1104-1106, 1120, 1186, 1272-1273, 1291, 1305-1306, 1314, 1344, 1357-1360, 1378-1381, 1445, 1483, 1573, 1651, 1661, 1671, 1680, 1686, 1692-1695, 1973, 2250, 2344, 2426-2432, 2576, 2675, 2698-2726, 2738-2743
R/tt_afun_utils.R              345      25  92.75%   44, 146, 152, 160-169, 218, 229-230, 452, 459-460, 524-526, 545, 559-560
R/tt_compare_tables.R           65       4  93.85%   56, 170, 248, 251
R/tt_compatibility.R           413      50  87.89%   19, 137-138, 187, 191, 321-322, 325-328, 335, 338, 365, 371-372, 442, 484, 513, 531, 555-556, 596, 609-611, 680, 705-708, 717, 769, 775, 782-783, 887, 893, 919-931, 960-961
R/tt_dotabulation.R            875      60  93.14%   36, 202, 204, 247, 268, 271-272, 318, 350-351, 372, 379-380, 460, 582-584, 633, 636, 665, 852, 855, 882, 993-994, 1149-1153, 1250, 1343-1351, 1367-1370, 1381, 1385, 1390-1392, 1402, 1406, 1426, 1510-1524
R/tt_export.R                  202      36  82.18%   47, 63, 104-105, 136, 175-177, 233-246, 398-399, 405, 448-454, 458-460, 556-557, 569
R/tt_from_df.R                   9       0  100.00%
R/tt_paginate.R                382      26  93.19%   47, 69, 100-105, 355, 456-457, 474-476, 619-620, 664-669, 733, 735, 744, 750, 753
R/tt_pos_and_access.R          519      37  92.87%   73, 75-76, 100, 152, 187-189, 234, 471, 473, 480, 486, 499, 508-509, 673, 684-686, 692-695, 723, 765-766, 776, 927-928, 976-1000, 1224, 1294
R/tt_showmethods.R             121      20  83.47%   47, 73-87, 138, 154-157, 163, 170, 172-174, 252-253
R/tt_sort.R                     76       3  96.05%   211-212, 218
R/tt_toString.R                325      23  92.92%   112, 305, 318, 327, 334, 336, 342-352, 435, 489, 495, 704-729
R/utils.R                       15       1  93.33%   109
R/validate_table_struct.R       75      11  85.33%   76-79, 88-89, 129, 137-138, 191-192
R/Viewer.R                      56       9  83.93%   51, 55, 65-68, 87-88, 118
TOTAL                         6489     564  91.31%

Diff against main

Filename                     Stmts    Miss  Cover
-------------------------  -------  ------  --------
R/00tabletrees.R               +38      +5  -0.38%
R/colby_constructors.R          +7       0  +0.05%
R/index_footnotes.R             +2       0  +100.00%
R/make_split_fun.R             +97     +15  +84.54%
R/split_funs.R                  +3      -1  +0.33%
R/summary.R                     +4      +4  -1.95%
R/tree_accessors.R              +5      +6  -0.70%
R/tt_dotabulation.R           +138     +16  -0.89%
R/tt_export.R                  -27     -37  +14.06%
R/tt_paginate.R                 -1     +11  -2.89%
R/tt_pos_and_access.R           -1       0  -0.01%
R/tt_showmethods.R               0      -1  +0.83%
R/tt_sort.R                     -5      -3  +3.46%
R/tt_toString.R                +20      +1  +0.14%
R/utils.R                       +4       0  +2.42%
R/validate_table_struct.R      +75     +11  +85.33%
TOTAL                         +359     +27  +0.07%

Results for commit: 54fb8e7

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Contributor

github-actions bot commented Jul 27, 2023

Unit Tests Summary

    1 files    21 suites   1m 31s ⏱️
171 tests 171 ✔️ 0 💤 0
746 runs  746 ✔️ 0 💤 0

Results for commit 69f4444.

♻️ This comment has been updated with latest results.

@anajens anajens added the sme label Jul 27, 2023
Copy link
Contributor

@anajens anajens left a comment

Choose a reason for hiding this comment

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

Thanks @gmbecker. Here is my feedback on some minor things:

  1. I think it would be better if the analysis variable and analysis function are always annotated regardless of the type of table variants {1-4} as described in [Bug]: row_labels don't match docs in qtable() #698.
    If users think the default label is too long it can easily be changed with row_labels.

For example:

qtable(ex_adsl , col_vars = "ARM")

Should return

                   A: Drug X   B: Placebo   C: Combination
                    (N=134)     (N=134)        (N=132)    
——————————————————————————————————————————————————————————
STUDYID - count      134         134            132 
  1. What do you think about changing the default formatting of avar - afun label to afun(avar). For example, instead of AGE - max to max(AGE) ? Given that the purpose is exploratory, this would be a nice reminder to the person doing the analysis how the table calculations are done.

  2. This should throw an error as the row_labels length shouldn't exceed 1 for table variant {2}:

qtable(ex_adsl , row_vars = "STRATA2", col_vars = "ARM", avar = "AGE", afun = mean, 
       row_labels = c("ABC", "EFG", "HIJ"))
ABC                                          
EFG   A: Drug X   B: Placebo   C: Combination
HIJ    (N=134)     (N=134)        (N=132)    
—————————————————————————————————————————————
S1      34.10       36.46          35.70     
S2      33.38       34.40          35.24     
  1. For multi-row returning afun the length of row_labels should match the number of cells created by afun. Right now nothing happens but I think this should also throw an error. Same thing happens in the case of this table with the additional row_vars split:
qtable(ex_adsl, col_vars = "ARM", avar = "AGE", afun = fivenum3,
       row_labels = "ABC") 
AGE - fivenum3   A: Drug X   B: Placebo   C: Combination
                  (N=134)     (N=134)        (N=132)    
————————————————————————————————————————————————————————
                   21.00       21.00          20.00     
                   28.00       30.00          30.00     
                   33.00       35.00          35.00     
                   39.00       40.00          40.00     
                   50.00       62.00          69.00   

@gmbecker gmbecker requested a review from anajens August 8, 2023 21:28
@gmbecker
Copy link
Collaborator Author

gmbecker commented Aug 8, 2023

@anajens I didn't change the label display but both directions of row_labels - number of afun cells mismatch are now errors.

Also there are now separate qtable_layout and qtable functions, as we discussed.

Copy link
Contributor

@anajens anajens left a comment

Choose a reason for hiding this comment

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

It's working well. Please just add the NEWS update.

@anajens
Copy link
Contributor

anajens commented Aug 9, 2023

Also there are now separate qtable_layout and qtable functions, as we discussed.

Thanks! I think this is a good start but not exactly what I had in mind. I was thinking about being able to return the expression of the layout so users can see directly the connection from qtable to the layout framework. But that's probably a much bigger task for another day ( if users request this).

@gmbecker
Copy link
Collaborator Author

gmbecker commented Aug 9, 2023

Also there are now separate qtable_layout and qtable functions, as we discussed.

Thanks! I think this is a good start but not exactly what I had in mind. I was thinking about being able to return the expression of the layout so users can see directly the connection from qtable to the layout framework. But that's probably a much bigger task for another day ( if users request this).

That is possible to do but out of scope for this issue, as it would require non-trivial new development. It is a good idea though

@anajens
Copy link
Contributor

anajens commented Aug 11, 2023

New issue added: #711

@gmbecker gmbecker merged commit d9dfec0 into main Aug 11, 2023
17 checks passed
@gmbecker gmbecker deleted the 698_qtable_row_labels_fixes branch August 11, 2023 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: row_labels don't match docs in qtable()
3 participants