You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an issue related to #234 (#234) but for tbl_stack.
Stacking 2 tbl_summary objects with different numbers result only the Ns of the first object being displayed in the header. Kindly inform if it is possible to have the 2 stacked objects with separate Ns for instance in the "group_header " rows separating the stacked tables?
library(survival)
#> Warning: package 'survival' was built under R version 3.6.3
library(gtsummary)
#> Warning: package 'gtsummary' was built under R version 3.6.3# make dataset that is arbitrarily different sizetrial2<-trial %>%
dplyr::filter(age>30)
t1<-trial %>%
select(response, trt, grade, age) %>%
tbl_summary(by=trt) %>%
add_p(pvalue_fun=function(x) style_pvalue(x, digits=2)) %>%
add_stat_label()
t1
Characteristic
Drug A, N = 98
Drug B, N = 102
p-value1
Tumor Response, n (%)
28 (29%)
33 (34%)
0.64
Unknown
3
4
Grade, n (%)
0.87
I
35 (36%)
33 (32%)
II
32 (33%)
36 (35%)
III
31 (32%)
33 (32%)
Age, yrs, median (IQR)
46 (37, 59)
48 (39, 56)
0.72
Unknown
7
4
1
Statistical tests performed: chi-square test of independence; Wilcoxon rank-sum test
# table with different sample sizet2<-trial2 %>%
select(response, trt, grade, age) %>%
tbl_summary(by=trt) %>%
add_p(pvalue_fun=function(x) style_pvalue(x, digits=2)) %>%
add_stat_label()
t2
Characteristic
Drug A, N = 83
Drug B, N = 88
p-value1
Tumor Response, n (%)
26 (32%)
28 (33%)
0.99
Unknown
2
4
Grade, n (%)
0.81
I
30 (36%)
28 (32%)
II
26 (31%)
31 (35%)
III
27 (33%)
29 (33%)
Age, yrs, median (IQR)
48 (38, 60)
49 (43, 57)
0.55
1
Statistical tests performed: chi-square test of independence; Wilcoxon rank-sum test
I am generally in favor of these kinds of consistency checks. The issue we'd encounter implementing something like this is that tbl_stack() is a general function that accepts any type of {gtsummary} object (and this includes objects outside the package that follow the general gtsummary structure with class gtsummary). Because there are may different type of objects that can be stacked, adding checks can be tricky.
For this example, I would recommend removing the Ns from the header to a column with the add_n() function, like in the example below. Happy Coding! 🕺
This is an issue related to #234 (#234) but for tbl_stack.
Stacking 2 tbl_summary objects with different numbers result only the Ns of the first object being displayed in the header. Kindly inform if it is possible to have the 2 stacked objects with separate Ns for instance in the "group_header " rows separating the stacked tables?
Characteristic
Drug A, N = 98
Drug B, N = 102
p-value1
Tumor Response, n (%)
28 (29%)
33 (34%)
0.64
Unknown
3
4
Grade, n (%)
0.87
I
35 (36%)
33 (32%)
II
32 (33%)
36 (35%)
III
31 (32%)
33 (32%)
Age, yrs, median (IQR)
46 (37, 59)
48 (39, 56)
0.72
Unknown
7
4
1
Statistical tests performed: chi-square test of independence; Wilcoxon rank-sum test
Characteristic
Drug A, N = 83
Drug B, N = 88
p-value1
Tumor Response, n (%)
26 (32%)
28 (33%)
Unknown
2
4
Grade, n (%)
0.81
I
30 (36%)
28 (32%)
II
26 (31%)
31 (35%)
III
27 (33%)
29 (33%)
Age, yrs, median (IQR)
48 (38, 60)
49 (43, 57)
0.55
1
Statistical tests performed: chi-square test of independence; Wilcoxon rank-sum test
Characteristic
Drug A, N = 98
Drug B, N = 102
p-value1
All
Tumor Response, n (%)
28 (29%)
33 (34%)
0.64
Unknown
3
4
Grade, n (%)
0.87
I
35 (36%)
33 (32%)
II
32 (33%)
36 (35%)
III
31 (32%)
33 (32%)
Age, yrs, median (IQR)
46 (37, 59)
48 (39, 56)
0.72
Unknown
7
4
Over 30
Tumor Response, n (%)
26 (32%)
28 (33%)
Unknown
2
4
Grade, n (%)
0.81
I
30 (36%)
28 (32%)
II
26 (31%)
31 (35%)
III
27 (33%)
29 (33%)
Age, yrs, median (IQR)
48 (38, 60)
49 (43, 57)
0.55
1
Statistical tests performed: chi-square test of independence; Wilcoxon rank-sum test
Created on 2020-07-18 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: