library(readxl)
ls <- read_excel("C:/dl/data/R-Rstudio/ls.xlsx", 
    col_types = c("text", "numeric", "numeric", 
        "numeric", "numeric", "text", "numeric", 
        "text", "text", "text", "text", "text", 
        "text", "text", "text"))
View(ls)
#Kiểm định phân phối chuẩn
shapiro.test(ls$hr)
## 
##  Shapiro-Wilk normality test
## 
## data:  ls$hr
## W = 0.92866, p-value = 4.499e-07
shapiro.test(ls$HATTh)
## 
##  Shapiro-Wilk normality test
## 
## data:  ls$HATTh
## W = 0.98632, p-value = 0.1233
shapiro.test(ls$HATTr)
## 
##  Shapiro-Wilk normality test
## 
## data:  ls$HATTr
## W = 0.94969, p-value = 1.907e-05
shapiro.test(ls$GRACE)
## 
##  Shapiro-Wilk normality test
## 
## data:  ls$GRACE
## W = 0.97778, p-value = 0.01187
shapiro.test(ls$TIMI)
## 
##  Shapiro-Wilk normality test
## 
## data:  ls$TIMI
## W = 0.92435, p-value = 2.261e-07
#Đặc điểm về lâm sàng của dân số nghiên cứu
library(gtsummary)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
summary2 <- ls %>%
select(hr, HATTh, HATTr, GRACE, ClassGRACE, TIMI, ClassTIMI, `STEMI-equi`, Wellen, HyperT, postMI, Sgarbossa, KILLIP, 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(
      hr ~ "Nhịp tim",
      HATTh ~ "HA tâm thu",
      HATTr ~ "HA tâm trương",
      GRACE ~ "Điểm nguy cơ GRACE",
      ClassGRACE ~ "Phân nhóm nguy cơ theo GRACE",
      TIMI ~ "Điểm nguy cơ TIMI",
      ClassTIMI ~ "Phân nhóm nguy cơ theo TIMI",
      `STEMI-equi` ~ "ECG có dấu hiệu STEMI equivalent",
      Wellen ~ "Hội chứng Wellen",
      HyperT ~ "Hyperacute T wave",
      postMI ~ "Dấu NMCT thành sau",
      Sgarbossa ~ "Block nhánh trái thỏa Sgarbossa",
      KILLIP ~ "Killip"
    ),
    missing_text = "(Missing)"
   ) %>%
  add_p(test = list(
    HATTh ~ "t.test", 
    hr ~ "wilcox.test",
    HATTr ~ "wilcox.test",
    GRACE ~ "wilcox.test",
    TIMI ~ "wilcox.test",
    ClassGRACE ~ "chisq.test",
    ClassTIMI ~ "chisq.test",
    `STEMI-equi` ~ "chisq.test",
    Wellen ~ "chisq.test",
    HyperT ~ "chisq.test",
    postMI ~ "chisq.test",
    Sgarbossa ~ "chisq.test",
    KILLIP ~ "chisq.test"),
    pvalue_fun = ~ style_pvalue(.x, digits = 2)) %>%
  add_overall() %>%
  add_n() %>%
  modify_caption("*Đặc điểm về lâm sàng của dân số nghiên cứu *")
## The following errors were returned during `modify_caption()`:
## ✖ For variable `Sgarbossa` (`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 `ClassTIMI` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `HyperT` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `KILLIP` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `Wellen` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
## ! For variable `postMI` (`TOCA`) and "statistic", "p.value", and "parameter"
##   statistics: Chi-squared approximation may be incorrect
summary2
*Đặc điểm về lâm sàng 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
Nhịp tim 158


0.56
    Mean (SD)
85.72 (19.14) 86.55 (18.43) 83.11 (21.27)
    Median (Q1, Q3)
84.00 (74.00, 98.00) 83.50 (77.00, 98.00) 84.50 (70.00, 96.00)
    Min, Max
30.00, 192.00 50.00, 192.00 30.00, 141.00
HA tâm thu 158


0.024
    Mean (SD)
140.85 (28.78) 143.96 (27.61) 131.05 (30.56)
    Median (Q1, Q3)
140.00 (120.00, 160.00) 140.00 (120.00, 160.00) 135.00 (110.00, 160.00)
    Min, Max
60.00, 230.00 70.00, 230.00 60.00, 200.00
HA tâm trương 158


0.30
    Mean (SD)
81.17 (15.96) 82.13 (15.28) 78.16 (17.84)
    Median (Q1, Q3)
80.00 (70.00, 90.00) 80.00 (70.00, 90.00) 80.00 (60.00, 90.00)
    Min, Max
40.00, 136.00 40.00, 136.00 40.00, 120.00
Điểm nguy cơ GRACE 158


0.88
    Mean (SD)
131.58 (33.40) 130.84 (31.99) 133.89 (37.88)
    Median (Q1, Q3)
132.50 (108.00, 148.00) 133.50 (108.00, 149.00) 129.00 (112.00, 148.00)
    Min, Max
61.00, 245.00 61.00, 237.00 62.00, 245.00
Phân nhóm nguy cơ theo GRACE 158


0.64
    0
40 / 158 (25%) 32 / 120 (27%) 8 / 38 (21%)
    1
57 / 158 (36%) 41 / 120 (34%) 16 / 38 (42%)
    2
61 / 158 (39%) 47 / 120 (39%) 14 / 38 (37%)
Điểm nguy cơ TIMI 158


0.24
    1
8 / 158 (5.1%) 7 / 120 (5.8%) 1 / 38 (2.6%)
    2
38 / 158 (24%) 30 / 120 (25%) 8 / 38 (21%)
    3
52 / 158 (33%) 40 / 120 (33%) 12 / 38 (32%)
    4
42 / 158 (27%) 31 / 120 (26%) 11 / 38 (29%)
    5
16 / 158 (10%) 10 / 120 (8.3%) 6 / 38 (16%)
    6
1 / 158 (0.6%) 1 / 120 (0.8%) 0 / 38 (0%)
    7
1 / 158 (0.6%) 1 / 120 (0.8%) 0 / 38 (0%)
Phân nhóm nguy cơ theo TIMI 158


0.48
    0
46 / 158 (29%) 37 / 120 (31%) 9 / 38 (24%)
    1
110 / 158 (70%) 81 / 120 (68%) 29 / 38 (76%)
    2
2 / 158 (1.3%) 2 / 120 (1.7%) 0 / 38 (0%)
ECG có dấu hiệu STEMI equivalent 158


0.80
    0
133 / 158 (84%) 102 / 120 (85%) 31 / 38 (82%)
    1
25 / 158 (16%) 18 / 120 (15%) 7 / 38 (18%)
Hội chứng Wellen 158


>0.99
    0
141 / 158 (89%) 107 / 120 (89%) 34 / 38 (89%)
    1
17 / 158 (11%) 13 / 120 (11%) 4 / 38 (11%)
Hyperacute T wave 158


>0.99
    0
152 / 158 (96%) 115 / 120 (96%) 37 / 38 (97%)
    1
6 / 158 (3.8%) 5 / 120 (4.2%) 1 / 38 (2.6%)
Dấu NMCT thành sau 158


0.090
    0
156 / 158 (99%) 120 / 120 (100%) 36 / 38 (95%)
    1
2 / 158 (1.3%) 0 / 120 (0%) 2 / 38 (5.3%)
Block nhánh trái thỏa Sgarbossa 158



    0
158 / 158 (100%) 120 / 120 (100%) 38 / 38 (100%)
Killip 158


0.093
    1
148 / 158 (94%) 114 / 120 (95%) 34 / 38 (89%)
    2
1 / 158 (0.6%) 0 / 120 (0%) 1 / 38 (2.6%)
    3
6 / 158 (3.8%) 5 / 120 (4.2%) 1 / 38 (2.6%)
    4
3 / 158 (1.9%) 1 / 120 (0.8%) 2 / 38 (5.3%)
1 n / N (%)
2 Wilcoxon rank sum test; Welch Two Sample t-test; Pearson’s Chi-squared test