library(readxl)
Tiencan <- read_excel("C:/dl/data/R-Rstudio/Tiencan.xlsx",
col_types = c("text", "text", "text", "text",
"text", "text", "numeric","text", "text", "text",
"text", "text", "text", "text", "text"))
View(Tiencan)
#Đặc điểm về tiền căn của dân số nghiên cứu
library(gtsummary)
summary2 <- Tiencan %>%
select(tha, dtd, dysl, htl, family, mi, PCItc, CABG, CVA, PAD, Renal, Pulmonary, 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(
tha ~ "Tăng huyết áp",
dtd ~ "Đái tháo đường",
dysl ~ "Rối loạn lipid máu",
htl ~ "Hút thuốc lá",
family ~ "Tiền căn gia đình có BMV sớm",
mi ~ "Nhồi máu cơ tim",
PCItc ~ "PCI",
CABG ~ "Phẫu thuật bắc cầu",
CVA ~ "Đột quỵ",
PAD ~ "Bệnh động mạch ngoại biên",
Renal ~ "Bệnh thận mạn",
Pulmonary ~ "Bệnh phổi mạn"
),
missing_text = "(Missing)"
) %>%
add_p(
pvalue_fun = ~ style_pvalue(.x, digits = 2)) %>%
add_overall() %>%
add_n() %>%
modify_caption("*Đặc điểm về tiền căn của dân số nghiên cứu *")
## The following errors were returned during `modify_caption()`:
## ✖ For variable `CABG` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: 'x' and 'y' must have at least 2 levels
## ✖ For variable `PAD` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: 'x' and 'y' must have at least 2 levels
## ✖ For variable `family` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: 'x' and 'y' must have at least 2 levels
summary2
| Characteristic | N | Overall N = 1581 |
0 N = 1201 |
1 N = 381 |
p-value2 |
|---|---|---|---|---|---|
| Tăng huyết áp | 158 | 0.20 | |||
| 0 | 15 / 158 (9.5%) | 9 / 120 (7.5%) | 6 / 38 (16%) | ||
| 1 | 143 / 158 (91%) | 111 / 120 (93%) | 32 / 38 (84%) | ||
| Đái tháo đường | 158 | 0.61 | |||
| 0 | 97 / 158 (61%) | 75 / 120 (63%) | 22 / 38 (58%) | ||
| 1 | 61 / 158 (39%) | 45 / 120 (38%) | 16 / 38 (42%) | ||
| Rối loạn lipid máu | 158 | 0.10 | |||
| 0 | 57 / 158 (36%) | 39 / 120 (33%) | 18 / 38 (47%) | ||
| 1 | 101 / 158 (64%) | 81 / 120 (68%) | 20 / 38 (53%) | ||
| Hút thuốc lá | 158 | 0.14 | |||
| 0 | 105 / 158 (66%) | 76 / 120 (63%) | 29 / 38 (76%) | ||
| 1 | 53 / 158 (34%) | 44 / 120 (37%) | 9 / 38 (24%) | ||
| Tiền căn gia đình có BMV sớm | 158 | ||||
| 0 | 158 / 158 (100%) | 120 / 120 (100%) | 38 / 38 (100%) | ||
| Nhồi máu cơ tim | 158 | >0.99 | |||
| 0 | 150 / 158 (95%) | 114 / 120 (95%) | 36 / 38 (95%) | ||
| 1 | 8 / 158 (5.1%) | 6 / 120 (5.0%) | 2 / 38 (5.3%) | ||
| PCI | 158 | 0.34 | |||
| 0 | 153 / 158 (97%) | 115 / 120 (96%) | 38 / 38 (100%) | ||
| 1 | 5 / 158 (3.2%) | 5 / 120 (4.2%) | 0 / 38 (0%) | ||
| Phẫu thuật bắc cầu | 158 | ||||
| 0 | 158 / 158 (100%) | 120 / 120 (100%) | 38 / 38 (100%) | ||
| Đột quỵ | 158 | 0.59 | |||
| 0 | 153 / 158 (97%) | 117 / 120 (98%) | 36 / 38 (95%) | ||
| 1 | 5 / 158 (3.2%) | 3 / 120 (2.5%) | 2 / 38 (5.3%) | ||
| Bệnh động mạch ngoại biên | 158 | ||||
| 0 | 158 / 158 (100%) | 120 / 120 (100%) | 38 / 38 (100%) | ||
| Bệnh thận mạn | 158 | 0.067 | |||
| 0 | 147 / 158 (93%) | 109 / 120 (91%) | 38 / 38 (100%) | ||
| 1 | 11 / 158 (7.0%) | 11 / 120 (9.2%) | 0 / 38 (0%) | ||
| Bệnh phổi mạn | 158 | >0.99 | |||
| 0 | 155 / 158 (98%) | 117 / 120 (98%) | 38 / 38 (100%) | ||
| 1 | 3 / 158 (1.9%) | 3 / 120 (2.5%) | 0 / 38 (0%) | ||
| 1 n / N (%) | |||||
| 2 Fisher’s exact test; Pearson’s Chi-squared test | |||||
#Số yếu tố nguy cơ tim mạch
summary3 <- Tiencan %>%
select(tong, 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(
tong ~ "Số yếu tố nguy cơ tim mạch"
),
missing_text = "(Missing)"
) %>%
add_p(
pvalue_fun = ~ style_pvalue(.x, digits = 2)) %>%
add_overall() %>%
add_n() %>%
modify_caption("*Sô yếu tố nguy cơ *")
summary3
| Characteristic | N | Overall N = 1581 |
0 N = 1201 |
1 N = 381 |
p-value2 |
|---|---|---|---|---|---|
| Số yếu tố nguy cơ tim mạch | 158 | 0.088 | |||
| 0 | 4 / 158 (2.5%) | 1 / 120 (0.8%) | 3 / 38 (7.9%) | ||
| 1 | 30 / 158 (19%) | 23 / 120 (19%) | 7 / 38 (18%) | ||
| 2 | 54 / 158 (34%) | 38 / 120 (32%) | 16 / 38 (42%) | ||
| 3 | 60 / 158 (38%) | 50 / 120 (42%) | 10 / 38 (26%) | ||
| 4 | 10 / 158 (6.3%) | 8 / 120 (6.7%) | 2 / 38 (5.3%) | ||
| 1 n / N (%) | |||||
| 2 Fisher’s exact test | |||||
#Tính median và IQR cho TOCA
median_value <- median(Tiencan$tong[Tiencan$TOCA == "1"], na.rm = TRUE)
IQR_value <- IQR(Tiencan$tong[Tiencan$TOCA == "1"], na.rm = TRUE)
print(paste("Median for 1:", median_value))
## [1] "Median for 1: 2"
print(paste("IQR for 1:", IQR_value))
## [1] "IQR for 1: 1.75"