This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

 library(gtsummary)

##Univaraite Analysis

tbl_summary(trial)
Characteristic N = 2001
Chemotherapy Treatment
    Drug A 98 (49%)
    Drug B 102 (51%)
Age 47 (38, 57)
    Unknown 11
Marker Level (ng/mL) 0.64 (0.22, 1.41)
    Unknown 10
T Stage
    T1 53 (27%)
    T2 54 (27%)
    T3 43 (22%)
    T4 50 (25%)
Grade
    I 68 (34%)
    II 68 (34%)
    III 64 (32%)
Tumor Response 61 (32%)
    Unknown 7
Patient Died 112 (56%)
Months to Death/Censor 22.4 (15.9, 24.0)
1 n (%); Median (Q1, Q3)
## Table printed with {flextable}, not {gt}. Learn why at
 ## https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html
 ## To suppress this message, include `message = FALSE` in the code 

##Bi variate Analysis

trial %>%
   tbl_summary(by = trt) %>%
   add_p() %>%
   add_overall() %>%
   add_n()
Characteristic N Overall
N = 200
1
Drug A
N = 98
1
Drug B
N = 102
1
p-value2
Age 189 47 (38, 57) 46 (37, 60) 48 (39, 56) 0.7
    Unknown
11 7 4
Marker Level (ng/mL) 190 0.64 (0.22, 1.41) 0.84 (0.23, 1.60) 0.52 (0.18, 1.21) 0.085
    Unknown
10 6 4
T Stage 200


0.9
    T1
53 (27%) 28 (29%) 25 (25%)
    T2
54 (27%) 25 (26%) 29 (28%)
    T3
43 (22%) 22 (22%) 21 (21%)
    T4
50 (25%) 23 (23%) 27 (26%)
Grade 200


0.9
    I
68 (34%) 35 (36%) 33 (32%)
    II
68 (34%) 32 (33%) 36 (35%)
    III
64 (32%) 31 (32%) 33 (32%)
Tumor Response 193 61 (32%) 28 (29%) 33 (34%) 0.5
    Unknown
7 3 4
Patient Died 200 112 (56%) 52 (53%) 60 (59%) 0.4
Months to Death/Censor 200 22.4 (15.9, 24.0) 23.5 (17.4, 24.0) 21.2 (14.5, 24.0) 0.14
1 Median (Q1, Q3); n (%)
2 Wilcoxon rank sum test; Pearson’s Chi-squared test
## Table printed with {flextable}, not {gt}. Learn why at
 ## https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html
 ## To suppress this message, include `message = FALSE` in the code 

##Fit a linear regression model

model <- lm(response ~  trt, data = trial)
 # Create a summary table
 tbl_regression(model)
Characteristic Beta 95% CI p-value
Chemotherapy Treatment


    Drug A
    Drug B 0.04 -0.09, 0.17 0.5
Abbreviation: CI = Confidence Interval
## Table printed with {flextable}, not {gt}. Learn why at
 ## https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html
 ## To suppress this message, include `message = FALSE` in the code chunk header.

#Fit a multiple linear regression model

model <- lm(response ~ age + trt + grade, data = trial)
 # Create a summary table
 tbl_regression(model)
Characteristic Beta 95% CI p-value
Age 0.00 0.00, 0.01 0.10
Chemotherapy Treatment


    Drug A
    Drug B 0.03 -0.11, 0.16 0.7
Grade


    I
    II -0.03 -0.20, 0.13 0.7
    III 0.00 -0.16, 0.17 >0.9
Abbreviation: CI = Confidence Interval
## Table printed with {flextable}, not {gt}. Learn why at
 ## https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html
 ## To suppress this message, include `message = FALSE` in the code