library(readxl)
outcome <- read_excel("C:/dl/data/R-Rstudio/outcome.xlsx",
col_types = c("text", "text", "text",
"text", "text", "text", "text", "text",
"text", "text", "text", "text"))
View(outcome)
head(outcome)
## # A tibble: 6 × 12
## `Số PCI` AF VT RLN MACCE AHF DQ `Recur-MI` death bleeding PCIk
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 7601 1 0 1 0 0 0 0 0 0 1
## 2 7620 0 0 0 0 0 0 0 0 0 1
## 3 7644 0 0 0 0 0 0 0 0 0 1
## 4 7648 0 0 0 0 0 0 0 0 0 1
## 5 7669 0 0 0 0 0 0 0 0 0 1
## 6 7673 0 0 0 0 0 0 0 0 0 1
## # ℹ 1 more variable: TOCA <chr>
library(gtsummary)
library(ggplot2)
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
# Chuyển đổi biến TOCA thành yếu tố (factor) với các nhãn tương ứng
outcome <- outcome %>%
mutate(TOCA = factor(TOCA, levels = c(0, 1), labels = c("không tắc hoàn toàn", "tắc hoàn toàn")))
# Tạo bảng tóm tắt đặc điểm outcome của dân số nghiên cứu
library(gtsummary)
library(ggplot2)
library(dplyr)
summary2 <- outcome %>%
select(AF, VT, RLN, MACCE, AHF, DQ, `Recur-MI`, death, bleeding, PCIk, 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(
PCIk ~ "Bệnh nhân được can thiệp ĐMV qua da",
AF ~ "Rung nhĩ",
VT ~ "Nhanh thất, rung thất",
RLN ~ "Rối loạn nhịp",
MACCE ~ "Biến cố tim mạch chính",
AHF ~ "Suy tim cấp",
DQ ~ "Đột quỵ",
`Recur-MI` ~ "Tái NMCT",
death ~ "Tử vong",
bleeding ~ "Xuất huyết"),
missing_text = "(Thiếu)"
) %>%
add_p(test = list(
PCIk ~ "chisq.test",
AF ~ "chisq.test",
VT ~ "chisq.test",
RLN ~ "chisq.test",
MACCE ~ "chisq.test",
AHF ~ "chisq.test",
DQ ~ "chisq.test",
`Recur-MI` ~ "chisq.test",
death ~ "chisq.test",
bleeding ~ "chisq.test"
),
pvalue_fun = ~ style_pvalue(.x, digits = 2)) %>%
add_overall() %>%
add_n() %>%
modify_caption("Đặc điểm kết cục nội viện của dân số nghiên cứu")
## The following errors were returned during `modify_caption()`:
## ✖ For variable `Recur-MI` (`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 `AF` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `AHF` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `DQ` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `MACCE` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `PCIk` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `RLN` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `VT` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `bleeding` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
## ! For variable `death` (`TOCA`) and "statistic", "p.value", and "parameter"
## statistics: Chi-squared approximation may be incorrect
# Xem kết quả
summary2
| Characteristic | N | Overall N = 1581 |
không tắc hoàn toàn N = 1201 |
tắc hoàn toàn N = 381 |
p-value2 |
|---|---|---|---|---|---|
| Rung nhĩ | 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%) | ||
| Nhanh thất, rung thất | 158 | 0.97 | |||
| 0 | 156 / 158 (99%) | 119 / 120 (99%) | 37 / 38 (97%) | ||
| 1 | 2 / 158 (1.3%) | 1 / 120 (0.8%) | 1 / 38 (2.6%) | ||
| Rối loạn nhịp | 158 | 0.17 | |||
| 0 | 153 / 158 (97%) | 118 / 120 (98%) | 35 / 38 (92%) | ||
| 1 | 5 / 158 (3.2%) | 2 / 120 (1.7%) | 3 / 38 (7.9%) | ||
| Biến cố tim mạch chính | 158 | >0.99 | |||
| 0 | 151 / 158 (96%) | 115 / 120 (96%) | 36 / 38 (95%) | ||
| 1 | 7 / 158 (4.4%) | 5 / 120 (4.2%) | 2 / 38 (5.3%) | ||
| Suy tim cấp | 158 | 0.96 | |||
| 0 | 152 / 158 (96%) | 116 / 120 (97%) | 36 / 38 (95%) | ||
| 1 | 6 / 158 (3.8%) | 4 / 120 (3.3%) | 2 / 38 (5.3%) | ||
| Đột quỵ | 158 | >0.99 | |||
| 0 | 157 / 158 (99%) | 119 / 120 (99%) | 38 / 38 (100%) | ||
| 1 | 1 / 158 (0.6%) | 1 / 120 (0.8%) | 0 / 38 (0%) | ||
| Tái NMCT | 158 | ||||
| 0 | 158 / 158 (100%) | 120 / 120 (100%) | 38 / 38 (100%) | ||
| Tử vong | 158 | >0.99 | |||
| 0 | 156 / 158 (99%) | 118 / 120 (98%) | 38 / 38 (100%) | ||
| 1 | 2 / 158 (1.3%) | 2 / 120 (1.7%) | 0 / 38 (0%) | ||
| Xuất huyết | 157 | 0.98 | |||
| 0 | 155 / 157 (99%) | 118 / 119 (99%) | 37 / 38 (97%) | ||
| 1 | 2 / 157 (1.3%) | 1 / 119 (0.8%) | 1 / 38 (2.6%) | ||
| (Thiếu) | 1 | 1 | 0 | ||
| Bệnh nhân được can thiệp ĐMV qua da | 158 | 0.46 | |||
| 0 | 7 / 158 (4.4%) | 4 / 120 (3.3%) | 3 / 38 (7.9%) | ||
| 1 | 151 / 158 (96%) | 116 / 120 (97%) | 35 / 38 (92%) | ||
| 1 n / N (%) | |||||
| 2 Pearson’s Chi-squared test | |||||