library(readxl)
DSA <- read_excel("C:/dl/data/R-Rstudio/DSA.xlsx", 
    col_types = c("text", "text", "text", 
        "text", "text", "text", "text", "text", 
        "text", "text", "text", "text", "text", 
        "text", "text", "text", "numeric", 
        "numeric", "text", "numeric"))
View(DSA)
head(DSA)
## # A tibble: 6 × 20
##   `Số PCI` AmitDSA SymtompDSA IABP  tkch  hstp  Culprit preTI postTI Predominant
##   <chr>    <chr>   <chr>      <chr> <chr> <chr> <chr>   <chr> <chr>  <chr>      
## 1 7601     1       1          0     0     0     2       1     3      1          
## 2 7620     0       1          0     0     0     1       2     3      1          
## 3 7644     0       0          0     0     0     1       0     3      1          
## 4 7648     1       1          0     0     0     1       1     3      1          
## 5 7669     1       1          0     0     0     1       3     3      1          
## 6 7673     0       0          0     0     0     2       0     3      1          
## # ℹ 10 more variables: TOCA <chr>, LM <chr>, multives <chr>,
## #   Multivesseld <chr>, THBH <chr>, RENTROP <chr>, `Admitto-DSA` <dbl>,
## #   AtoD <dbl>, `Symtompto-DSA` <chr>, StoD <dbl>
#Kiểm định phân phối chuẩn
shapiro.test(DSA$AtoD)
## 
##  Shapiro-Wilk normality test
## 
## data:  DSA$AtoD
## W = 0.85488, p-value = 3.365e-11
shapiro.test(DSA$StoD)
## 
##  Shapiro-Wilk normality test
## 
## data:  DSA$StoD
## W = 0.9084, p-value = 2.119e-08
#Đặc điểm CLS của dân số nghiên cứu
library(gtsummary)
library(ggplot2)
summary2 <- DSA %>%
  select(AtoD,  StoD, AmitDSA,  SymtompDSA, IABP,   tkch,   hstp,   Culprit,    preTI,  postTI, Predominant,    LM,  multives,  Multivesseld,   THBH,   RENTROP,    TOCA
) %>%
  tbl_summary(by = TOCA,
    type = all_continuous() ~ "continuous2",
    statistic = list(
      all_continuous() ~ c("{mean} ({sd})", "{median} ({p25}, {p75})", "{min}, {max}"),
      all_categorical() ~ "{n} / {N} ({p}%)"
    ),
    digits = all_continuous() ~ 2,
    label = list(
      AmitDSA ~ "Tgian từ NV-DSA > 24h",
      SymtompDSA ~ "tgian từ tch-DSA >24h",
      IABP ~ "IABP",
      tkch ~ "Thông khí cơ học",
      hstp ~ "Hồi sức tim phổi",
      Culprit ~ "ĐMV thủ phạm",
      preTI ~ "TIMI trước thủ thuật",
      postTI ~ "TIMI sau thủ thuật",
      Predominant ~ "ĐMV ưu thế",
      LM ~ "Bệnh nhánh LM",
      multives ~ "Số nhánh ĐMV bệnh",
      Multivesseld ~ "Bệnh đa nhánh mạch vành",
      THBH ~ "Tuần hoàn bàng hệ",
      RENTROP ~ "Phân loại THBH theo RENTROP",
      AtoD ~ "Thời gian từ lúc NV đến DSA (giờ)",
      StoD ~ "Thời gian từ lúc triệu chứng đến DSA (giờ)"
    ),
    missing_text = "(Missing)"
   ) %>%
  add_p(test = list(
    AtoD ~ "wilcox.test",
    StoD ~ "wilcox.test",
    multives ~ "chisq.test",
    AmitDSA ~ "chisq.test",
    SymtompDSA ~ "chisq.test",
    IABP ~ "chisq.test",
    tkch ~ "chisq.test",
    hstp ~ "chisq.test",
    Multivesseld ~ "chisq.test",
    LM ~ "chisq.test",
    Culprit ~ "chisq.test",
    preTI ~ "chisq.test",
    postTI ~ "chisq.test",
    Predominant ~ "chisq.test",
    THBH ~ "chisq.test",
    RENTROP ~ "chisq.test"),
    pvalue_fun = ~ style_pvalue(.x, digits = 2)) %>%
  add_overall() %>%
  add_n() %>%
  modify_caption("*Đặc điểm chụp mạch vành của dân số nghiên cứu *")
## The following errors were returned during `modify_caption()`:
## ✖ For variable `IABP` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: 'x' and 'y' must have at least 2 levels
## ✖ For variable `hstp` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: 'x' and 'y' must have at least 2 levels
## ✖ For variable `tkch` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: 'x' and 'y' must have at least 2 levels
## The following warnings were returned during `modify_caption()`:
## ! For variable `Culprit` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `LM` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `Predominant` (`TOCA`) and "statistic", "p.value", and
##   "parameter" statistics: Chi-squared approximation may be incorrect
## ! For variable `RENTROP` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `postTI` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `preTI` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
summary2
*Đặc điểm chụp mạch vành của dân số nghiên cứu *
Characteristic N Overall
N = 158
1
0
N = 120
1
1
N = 38
1
p-value2
Thời gian từ lúc NV đến DSA (giờ) 158


0.71
    Mean (SD)
60.65 (42.48) 60.23 (39.81) 62.00 (50.59)
    Median (Q1, Q3)
48.00 (24.00, 72.00) 48.00 (24.00, 72.00) 48.00 (24.00, 96.00)
    Min, Max
1.00, 240.00 1.00, 192.00 2.00, 240.00
Thời gian từ lúc triệu chứng đến DSA (giờ) 158


0.45
    Mean (SD)
77.42 (52.14) 78.45 (50.55) 74.17 (57.48)
    Median (Q1, Q3)
72.00 (24.00, 120.00) 72.00 (24.00, 120.00) 72.00 (24.00, 96.00)
    Min, Max
1.50, 240.00 1.50, 240.00 2.00, 240.00
Tgian từ NV-DSA > 24h 158


0.013
    0
27 / 158 (17%) 15 / 120 (13%) 12 / 38 (32%)
    1
131 / 158 (83%) 105 / 120 (88%) 26 / 38 (68%)
tgian từ tch-DSA >24h 158


0.014
    0
24 / 158 (15%) 13 / 120 (11%) 11 / 38 (29%)
    1
134 / 158 (85%) 107 / 120 (89%) 27 / 38 (71%)
IABP 158



    0
158 / 158 (100%) 120 / 120 (100%) 38 / 38 (100%)
Thông khí cơ học 158



    0
158 / 158 (100%) 120 / 120 (100%) 38 / 38 (100%)
Hồi sức tim phổi 158



    0
158 / 158 (100%) 120 / 120 (100%) 38 / 38 (100%)
ĐMV thủ phạm 158


<0.001
    1
77 / 158 (49%) 69 / 120 (58%) 8 / 38 (21%)
    2
48 / 158 (30%) 30 / 120 (25%) 18 / 38 (47%)
    3
32 / 158 (20%) 21 / 120 (18%) 11 / 38 (29%)
    4
1 / 158 (0.6%) 0 / 120 (0%) 1 / 38 (2.6%)
TIMI trước thủ thuật 158


<0.001
    0
26 / 158 (16%) 0 / 120 (0%) 26 / 38 (68%)
    1
12 / 158 (7.6%) 0 / 120 (0%) 12 / 38 (32%)
    2
47 / 158 (30%) 47 / 120 (39%) 0 / 38 (0%)
    3
73 / 158 (46%) 73 / 120 (61%) 0 / 38 (0%)
TIMI sau thủ thuật 158


0.013
    0
1 / 158 (0.6%) 0 / 120 (0%) 1 / 38 (2.6%)
    1
2 / 158 (1.3%) 0 / 120 (0%) 2 / 38 (5.3%)
    2
4 / 158 (2.5%) 4 / 120 (3.3%) 0 / 38 (0%)
    3
151 / 158 (96%) 116 / 120 (97%) 35 / 38 (92%)
ĐMV ưu thế 158


>0.99
    1
156 / 158 (99%) 118 / 120 (98%) 38 / 38 (100%)
    2
2 / 158 (1.3%) 2 / 120 (1.7%) 0 / 38 (0%)
Bệnh nhánh LM 158


>0.99
    0
147 / 158 (93%) 112 / 120 (93%) 35 / 38 (92%)
    1
11 / 158 (7.0%) 8 / 120 (6.7%) 3 / 38 (7.9%)
Số nhánh ĐMV bệnh 158


0.14
    1
35 / 158 (22%) 31 / 120 (26%) 4 / 38 (11%)
    2
62 / 158 (39%) 45 / 120 (38%) 17 / 38 (45%)
    3
61 / 158 (39%) 44 / 120 (37%) 17 / 38 (45%)
Bệnh đa nhánh mạch vành 158


0.079
    0
35 / 158 (22%) 31 / 120 (26%) 4 / 38 (11%)
    1
123 / 158 (78%) 89 / 120 (74%) 34 / 38 (89%)
Tuần hoàn bàng hệ 158


<0.001
    0
136 / 158 (86%) 111 / 120 (93%) 25 / 38 (66%)
    1
22 / 158 (14%) 9 / 120 (7.5%) 13 / 38 (34%)
Phân loại THBH theo RENTROP 158


<0.001
    0
136 / 158 (86%) 111 / 120 (93%) 25 / 38 (66%)
    1
11 / 158 (7.0%) 4 / 120 (3.3%) 7 / 38 (18%)
    2
11 / 158 (7.0%) 5 / 120 (4.2%) 6 / 38 (16%)
1 n / N (%)
2 Wilcoxon rank sum test; Pearson’s Chi-squared test