-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00_Introduction.R
More file actions
61 lines (40 loc) · 881 Bytes
/
Copy path00_Introduction.R
File metadata and controls
61 lines (40 loc) · 881 Bytes
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
# Install Packages
install.packages("tidyverse")
install.packages("gtsummary")
install.packages("gt")
# Load required packages
library(tidyverse)
library(gtsummary)
library(gt)
# To get help (package)
?tidyverse
?gtsummary
?gt
# To get help (function)
?mean
?tbl_summary
# Explore built-in datasets
data()
CO2
trial
# Use view
view(trial)
# tbl_summary (pipe - SHIFT + CLT + M)
trial |>
select(trt, age, grade) |>
tbl_summary(
by = trt,
missing = "no",
statistic = list(
all_continuous() ~ "{mean}({sd})",
all_categorical() ~ "{n}/{N}({p}%)"
),
digits = all_continuous() ~ 2,
label = grade ~ "Tumor Grade"
) |>
bold_labels() |>
italicize_labels() |>
add_p() |>
bold_p(t = 0.05) |>
as_gt() |>
gtsave("tables/sample_table.docx")