-
Notifications
You must be signed in to change notification settings - Fork 1
/
tables.Rmd
100 lines (81 loc) · 2.42 KB
/
tables.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
title: Tables
output:
rmarkdown::html_vignette:
toc_float: true
vignette: >
%\VignetteIndexEntry{Tables}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
Sys.setenv(LANGUAGE = "en")
library("sbcdata")
sbcdata
```
**Authors**: `r paste0(format(eval(parse(text = packageDescription("sbcdata")[["Authors@R"]])), include = c("given", "family", "role")), collapse =", ")`<br />
**Last modified:** `r file.info("flowcharts.Rmd")$mtime`<br />
**Compiled**: `r date()`
```{r dp}
sbcdata <- sbc_exclude_entries(sbcdata)
sbcdata <- sbcdata[(!Excluded),]
.lbl <- function(x, unit) {
if (nchar(unit))
paste0(x, " [", unit, "]")
else
x
}
for (i in seq_len(nrow(labcodes))) {
attr(sbcdata[[labcodes$Code[i]]], "label") <-
.lbl(labcodes$Code[i], labcodes$Unit[i])
}
```
# Baseline Leipzig
```{r baseline}
library("gtsummary")
theme_gtsummary_journal(journal = "nejm")
theme_gtsummary_compact()
ukl <- subset(sbcdata, Center == "Leipzig")
tblGeneral <- ukl[!duplicated(ukl$Id),] |>
select(Age, Sex, Diagnosis) |>
tbl_summary(by = Diagnosis, missing_text = "(Missing)") |>
add_p()
tblLabs <- ukl[, c("Diagnosis", labcodes$Code), with = FALSE] |>
tbl_summary(by = Diagnosis, missing_text = "(Missing)") |>
add_p()
tbl_stack(
list(add_n(tblGeneral), add_n(tblLabs)),
group_header = c("General", "Laboratory Diagnostics")
)
```
# Greifswald vs Leipzig
```{r umgvsukl}
tblGeneral <- sbcdata[
!duplicated(sbcdata[,c("Id", "Center"), with = FALSE]),
] |>
select(Age, Sex, Diagnosis, Center) |>
tbl_summary(by = Center, missing_text = "(Missing)") |>
add_p()
tblLabs <- sbcdata[, c("Center", labcodes$Code), with = FALSE] |>
tbl_summary(by = Center, missing_text = "(Missing)") |>
add_p()
tbl_stack(
list(add_n(tblGeneral), add_n(tblLabs)),
group_header = c("General", "Laboratory Diagnostics")
)
```
# Leipzig PCT
```{r pct}
pct <- ukl[sbcdata:::.is_cbc(ukl, labcodes$Code[-1], complete = TRUE), ]
tblGeneral <- pct[!duplicated(pct$Id),] |>
select(Age, Sex, Diagnosis) |>
tbl_summary(by = Diagnosis, missing_text = "(Missing)") |>
add_p()
tblLabs <- pct[, c("Diagnosis", labcodes$Code), with = FALSE] |>
tbl_summary(by = Diagnosis, missing_text = "(Missing)") |>
add_p()
tbl_stack(
list(add_n(tblGeneral), add_n(tblLabs)),
group_header = c("General", "Laboratory Diagnostics")
)
```