I followed the “Introduction to tableone” notes by Kazuki Yoshida (see: https://cran.r-project.org/web/packages/tableone/vignettes/introduction.html)
CreateTableOne(data = pbc)
Overall
n 418
id (mean (SD)) 209.50 (120.81)
time (mean (SD)) 1917.78 (1104.67)
status (mean (SD)) 0.83 (0.96)
trt (mean (SD)) 1.49 (0.50)
age (mean (SD)) 50.74 (10.45)
sex = f (%) 374 (89.5)
ascites (mean (SD)) 0.08 (0.27)
hepato (mean (SD)) 0.51 (0.50)
spiders (mean (SD)) 0.29 (0.45)
edema (mean (SD)) 0.10 (0.25)
bili (mean (SD)) 3.22 (4.41)
chol (mean (SD)) 369.51 (231.94)
albumin (mean (SD)) 3.50 (0.42)
copper (mean (SD)) 97.65 (85.61)
alk.phos (mean (SD)) 1982.66 (2140.39)
ast (mean (SD)) 122.56 (56.70)
trig (mean (SD)) 124.70 (65.15)
platelet (mean (SD)) 257.02 (98.33)
protime (mean (SD)) 10.73 (1.02)
stage (mean (SD)) 3.02 (0.88)
c("id", "time", "status", "trt", "age", "sex", "ascites", "hepato",
"spiders", "edema", "bili", "chol", "albumin", "copper", "alk.phos",
"ast", "trig", "platelet", "protime", "stage")
myVars <- c("time", "status", "trt", "age", "sex", "ascites", "hepato", "spiders", "edema", "bili", "chol", "albumin", "copper", "alk.phos", "ast", "trig", "platelet", "protime", "stage")
catVars <- c("status", "trt", "ascites", "hepato", "spiders", "edema", "stage")
tab2 <- CreateTableOne(vars = myVars, data = pbc, factorVars = catVars)
level Overall
n 418
time (mean (SD)) 1,917.78 (1,104.67)
status (%) 0 232 (55.5)
1 25 ( 6.0)
2 161 (38.5)
trt (%) 1 158 (50.6)
2 154 (49.4)
age (mean (SD)) 50.74 (10.45)
sex (%) m 44 (10.5)
f 374 (89.5)
ascites (%) 0 288 (92.3)
1 24 ( 7.7)
hepato (%) 0 152 (48.7)
1 160 (51.3)
spiders (%) 0 222 (71.2)
1 90 (28.8)
edema (%) 0 354 (84.7)
0.5 44 (10.5)
1 20 ( 4.8)
bili (mean (SD)) 3.22 (4.41)
chol (mean (SD)) 369.51 (231.94)
albumin (mean (SD)) 3.50 (0.42)
copper (mean (SD)) 97.65 (85.61)
alk.phos (mean (SD)) 1,982.66 (2,140.39)
ast (mean (SD)) 122.56 (56.70)
trig (mean (SD)) 124.70 (65.15)
platelet (mean (SD)) 257.02 (98.33)
protime (mean (SD)) 10.73 (1.02)
stage (%) 1 21 ( 5.1)
2 92 (22.3)
3 155 (37.6)
4 144 (35.0)
summary(tab2)
### Summary of continuous variables ###
strata: Overall
n miss p.miss mean sd median p25 p75 min max
time 418 0 0.0 1918 1e+03 1730 1e+03 2614 41.0 4795
age 418 0 0.0 51 1e+01 51 4e+01 58 26.3 78
bili 418 0 0.0 3 4e+00 1 8e-01 3 0.3 28
chol 418 134 32.1 370 2e+02 310 2e+02 400 120.0 1775
albumin 418 0 0.0 3 4e-01 4 3e+00 4 2.0 5
copper 418 108 25.8 98 9e+01 73 4e+01 123 4.0 588
alk.phos 418 106 25.4 1983 2e+03 1259 9e+02 1980 289.0 13862
ast 418 106 25.4 123 6e+01 115 8e+01 152 26.4 457
trig 418 136 32.5 125 7e+01 108 8e+01 151 33.0 598
platelet 418 11 2.6 257 1e+02 251 2e+02 318 62.0 721
protime 418 2 0.5 11 1e+00 11 1e+01 11 9.0 18
skew kurt
time 0.47 -0.5
age 0.09 -0.6
bili 2.72 8.1
chol 3.41 14.3
albumin -0.47 0.6
copper 2.30 7.6
alk.phos 2.99 9.7
ast 1.45 4.3
trig 2.52 11.8
platelet 0.63 0.9
protime 2.22 10.0
=======================================================================================
### Summary of categorical variables ###
strata: Overall
var n miss p.miss level freq percent cum.percent
status 418 0 0.0 0 232 55.5 55.5
1 25 6.0 61.5
2 161 38.5 100.0
trt 418 106 25.4 1 158 50.6 50.6
2 154 49.4 100.0
sex 418 0 0.0 m 44 10.5 10.5
f 374 89.5 100.0
ascites 418 106 25.4 0 288 92.3 92.3
1 24 7.7 100.0
hepato 418 106 25.4 0 152 48.7 48.7
1 160 51.3 100.0
spiders 418 106 25.4 0 222 71.2 71.2
1 90 28.8 100.0
edema 418 0 0.0 0 354 84.7 84.7
0.5 44 10.5 95.2
1 20 4.8 100.0
stage 418 6 1.4 1 21 5.1 5.1
2 92 22.3 27.4
3 155 37.6 65.0
4 144 35.0 100.0
biomarkers <- c("bili", "chol", "copper", "alk.phos", "trig", "protime")
print(tab2, nonnormal = biomarkers, formatOptions = list(big.mark = ","))
Overall
n 418
time (mean (SD)) 1,917.78 (1,104.67)
status (%)
0 232 (55.5)
1 25 ( 6.0)
2 161 (38.5)
trt = 2 (%) 154 (49.4)
age (mean (SD)) 50.74 (10.45)
sex = f (%) 374 (89.5)
ascites = 1 (%) 24 ( 7.7)
hepato = 1 (%) 160 (51.3)
spiders = 1 (%) 90 (28.8)
edema (%)
0 354 (84.7)
0.5 44 (10.5)
1 20 ( 4.8)
bili (median [IQR]) 1.40 [0.80, 3.40]
chol (median [IQR]) 309.50 [249.50, 400.00]
albumin (mean (SD)) 3.50 (0.42)
copper (median [IQR]) 73.00 [41.25, 123.00]
alk.phos (median [IQR]) 1,259.00 [871.50, 1,980.00]
ast (mean (SD)) 122.56 (56.70)
trig (median [IQR]) 108.00 [84.25, 151.00]
platelet (mean (SD)) 257.02 (98.33)
protime (median [IQR]) 10.60 [10.00, 11.10]
stage (%)
1 21 ( 5.1)
2 92 (22.3)
3 155 (37.6)
4 144 (35.0)
tab3 <- CreateTableOne(vars = myVars, strata = "trt", data = pbc, factorVars = catVars)
print(tab3, nonnormal = biomarkers, formatOptions = list(big.mark = ","))
Stratified by trt
1
n 158
time (mean (SD)) 2,015.62 (1,094.12)
status (%)
0 83 (52.5)
1 10 ( 6.3)
2 65 (41.1)
trt = 2 (%) 0 ( 0.0)
age (mean (SD)) 51.42 (11.01)
sex = f (%) 137 (86.7)
ascites = 1 (%) 14 ( 8.9)
hepato = 1 (%) 73 (46.2)
spiders = 1 (%) 45 (28.5)
edema (%)
0 132 (83.5)
0.5 16 (10.1)
1 10 ( 6.3)
bili (median [IQR]) 1.40 [0.80, 3.20]
chol (median [IQR]) 315.50 [247.75, 417.00]
albumin (mean (SD)) 3.52 (0.44)
copper (median [IQR]) 73.00 [40.00, 121.00]
alk.phos (median [IQR]) 1,214.50 [840.75, 2,028.00]
ast (mean (SD)) 120.21 (54.52)
trig (median [IQR]) 106.00 [84.50, 146.00]
platelet (mean (SD)) 258.75 (100.32)
protime (median [IQR]) 10.60 [10.03, 11.00]
stage (%)
1 12 ( 7.6)
2 35 (22.2)
3 56 (35.4)
4 55 (34.8)
Stratified by trt
2 p test
n 154
time (mean (SD)) 1,996.86 (1,155.93) 0.883
status (%) 0.894
0 85 ( 55.2)
1 9 ( 5.8)
2 60 ( 39.0)
trt = 2 (%) 154 (100.0) <0.001
age (mean (SD)) 48.58 (9.96) 0.018
sex = f (%) 139 ( 90.3) 0.421
ascites = 1 (%) 10 ( 6.5) 0.567
hepato = 1 (%) 87 ( 56.5) 0.088
spiders = 1 (%) 45 ( 29.2) 0.985
edema (%) 0.877
0 131 ( 85.1)
0.5 13 ( 8.4)
1 10 ( 6.5)
bili (median [IQR]) 1.30 [0.72, 3.60] 0.842 nonnorm
chol (median [IQR]) 303.50 [254.25, 377.00] 0.544 nonnorm
albumin (mean (SD)) 3.52 (0.40) 0.874
copper (median [IQR]) 73.00 [43.00, 139.00] 0.717 nonnorm
alk.phos (median [IQR]) 1,283.00 [922.50, 1,949.75] 0.812 nonnorm
ast (mean (SD)) 124.97 (58.93) 0.460
trig (median [IQR]) 113.00 [84.50, 155.00] 0.370 nonnorm
platelet (mean (SD)) 265.20 (90.73) 0.555
protime (median [IQR]) 10.60 [10.00, 11.40] 0.588 nonnorm
stage (%) 0.201
1 4 ( 2.6)
2 32 ( 20.8)
3 64 ( 41.6)
4 54 ( 35.1)
print(tab3, nonnormal = biomarkers, exact = "stage", smd = TRUE)
Stratified by trt
1
n 158
time (mean (SD)) 2015.62 (1094.12)
status (%)
0 83 (52.5)
1 10 ( 6.3)
2 65 (41.1)
trt = 2 (%) 0 ( 0.0)
age (mean (SD)) 51.42 (11.01)
sex = f (%) 137 (86.7)
ascites = 1 (%) 14 ( 8.9)
hepato = 1 (%) 73 (46.2)
spiders = 1 (%) 45 (28.5)
edema (%)
0 132 (83.5)
0.5 16 (10.1)
1 10 ( 6.3)
bili (median [IQR]) 1.40 [0.80, 3.20]
chol (median [IQR]) 315.50 [247.75, 417.00]
albumin (mean (SD)) 3.52 (0.44)
copper (median [IQR]) 73.00 [40.00, 121.00]
alk.phos (median [IQR]) 1214.50 [840.75, 2028.00]
ast (mean (SD)) 120.21 (54.52)
trig (median [IQR]) 106.00 [84.50, 146.00]
platelet (mean (SD)) 258.75 (100.32)
protime (median [IQR]) 10.60 [10.03, 11.00]
stage (%)
1 12 ( 7.6)
2 35 (22.2)
3 56 (35.4)
4 55 (34.8)
Stratified by trt
2 p test
n 154
time (mean (SD)) 1996.86 (1155.93) 0.883
status (%) 0.894
0 85 ( 55.2)
1 9 ( 5.8)
2 60 ( 39.0)
trt = 2 (%) 154 (100.0) <0.001
age (mean (SD)) 48.58 (9.96) 0.018
sex = f (%) 139 ( 90.3) 0.421
ascites = 1 (%) 10 ( 6.5) 0.567
hepato = 1 (%) 87 ( 56.5) 0.088
spiders = 1 (%) 45 ( 29.2) 0.985
edema (%) 0.877
0 131 ( 85.1)
0.5 13 ( 8.4)
1 10 ( 6.5)
bili (median [IQR]) 1.30 [0.72, 3.60] 0.842 nonnorm
chol (median [IQR]) 303.50 [254.25, 377.00] 0.544 nonnorm
albumin (mean (SD)) 3.52 (0.40) 0.874
copper (median [IQR]) 73.00 [43.00, 139.00] 0.717 nonnorm
alk.phos (median [IQR]) 1283.00 [922.50, 1949.75] 0.812 nonnorm
ast (mean (SD)) 124.97 (58.93) 0.460
trig (median [IQR]) 113.00 [84.50, 155.00] 0.370 nonnorm
platelet (mean (SD)) 265.20 (90.73) 0.555
protime (median [IQR]) 10.60 [10.00, 11.40] 0.588 nonnorm
stage (%) 0.205 exact
1 4 ( 2.6)
2 32 ( 20.8)
3 64 ( 41.6)
4 54 ( 35.1)
Stratified by trt
SMD
n
time (mean (SD)) 0.017
status (%) 0.054
0
1
2
trt = 2 (%) NaN
age (mean (SD)) 0.270
sex = f (%) 0.111
ascites = 1 (%) 0.089
hepato = 1 (%) 0.207
spiders = 1 (%) 0.016
edema (%) 0.058
0
0.5
1
bili (median [IQR]) 0.171
chol (median [IQR]) 0.038
albumin (mean (SD)) 0.018
copper (median [IQR]) <0.001
alk.phos (median [IQR]) 0.037
ast (mean (SD)) 0.084
trig (median [IQR]) 0.017
platelet (mean (SD)) 0.067
protime (median [IQR]) 0.146
stage (%) 0.246
1
2
3
4
tab3$CatTable
Stratified by trt
1 2 p test
n 158 154
status (%) 0.894
0 83 (52.5) 85 ( 55.2)
1 10 ( 6.3) 9 ( 5.8)
2 65 (41.1) 60 ( 39.0)
trt = 2 (%) 0 ( 0.0) 154 (100.0) <0.001
sex = f (%) 137 (86.7) 139 ( 90.3) 0.421
ascites = 1 (%) 14 ( 8.9) 10 ( 6.5) 0.567
hepato = 1 (%) 73 (46.2) 87 ( 56.5) 0.088
spiders = 1 (%) 45 (28.5) 45 ( 29.2) 0.985
edema (%) 0.877
0 132 (83.5) 131 ( 85.1)
0.5 16 (10.1) 13 ( 8.4)
1 10 ( 6.3) 10 ( 6.5)
stage (%) 0.201
1 12 ( 7.6) 4 ( 2.6)
2 35 (22.2) 32 ( 20.8)
3 56 (35.4) 64 ( 41.6)
4 55 (34.8) 54 ( 35.1)
print(tab3$ContTable, nonnormal = biomarkers)
Stratified by trt
1
n 158
time (mean (SD)) 2015.62 (1094.12)
age (mean (SD)) 51.42 (11.01)
bili (median [IQR]) 1.40 [0.80, 3.20]
chol (median [IQR]) 315.50 [247.75, 417.00]
albumin (mean (SD)) 3.52 (0.44)
copper (median [IQR]) 73.00 [40.00, 121.00]
alk.phos (median [IQR]) 1214.50 [840.75, 2028.00]
ast (mean (SD)) 120.21 (54.52)
trig (median [IQR]) 106.00 [84.50, 146.00]
platelet (mean (SD)) 258.75 (100.32)
protime (median [IQR]) 10.60 [10.03, 11.00]
Stratified by trt
2 p test
n 154
time (mean (SD)) 1996.86 (1155.93) 0.883
age (mean (SD)) 48.58 (9.96) 0.018
bili (median [IQR]) 1.30 [0.72, 3.60] 0.842 nonnorm
chol (median [IQR]) 303.50 [254.25, 377.00] 0.544 nonnorm
albumin (mean (SD)) 3.52 (0.40) 0.874
copper (median [IQR]) 73.00 [43.00, 139.00] 0.717 nonnorm
alk.phos (median [IQR]) 1283.00 [922.50, 1949.75] 0.812 nonnorm
ast (mean (SD)) 124.97 (58.93) 0.460
trig (median [IQR]) 113.00 [84.50, 155.00] 0.370 nonnorm
platelet (mean (SD)) 265.20 (90.73) 0.555
protime (median [IQR]) 10.60 [10.00, 11.40] 0.588 nonnorm