Can be add dependent label to final results dataframe.
dependent_label(df.out, .data, dependent, prefix = "Dependent: ", suffix = "")
Dataframe (results table) to be altered.
Original dataframe.
Character vector of length 1: quoted name of depdendent
variable. Can be continuous, a binary factor, or a survival object of form
Surv(time, status)
Prefix for dependent label
Suffix for dependent label
Returns the label for the dependent variable, if specified.
library(dplyr)
explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
explanatory_multi = c("age.factor", "obstruct.factor")
random_effect = "hospital"
dependent = 'mort_5yr'
# Separate tables
colon_s %>%
summary_factorlist(dependent, explanatory, fit_id=TRUE) -> example.summary
#> Note: dependent includes missing data. These are dropped.
colon_s %>%
glmuni(dependent, explanatory) %>%
fit2df(estimate_suffix=" (univariable)") -> example.univariable
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
colon_s %>%
glmmulti(dependent, explanatory) %>%
fit2df(estimate_suffix=" (multivariable)") -> example.multivariable
#> Waiting for profiling to be done...
colon_s %>%
glmmixed(dependent, explanatory, random_effect) %>%
fit2df(estimate_suffix=" (multilevel") -> example.multilevel
# Pipe together
example.summary %>%
finalfit_merge(example.univariable) %>%
finalfit_merge(example.multivariable) %>%
finalfit_merge(example.multilevel) %>%
select(-c(fit_id, index)) %>%
dependent_label(colon_s, dependent) -> example.final
example.final
#> Dependent: Mortality 5 year Alive Died
#> 3 Age <40 years 31 (6.1) 36 (8.9)
#> 1 40-59 years 208 (40.7) 131 (32.4)
#> 2 60+ years 272 (53.2) 237 (58.7)
#> 8 Sex Female 243 (47.6) 194 (48.0)
#> 9 Male 268 (52.4) 210 (52.0)
#> 4 Obstruction No 408 (82.1) 312 (78.6)
#> 5 Yes 89 (17.9) 85 (21.4)
#> 6 Perforation No 497 (97.3) 391 (96.8)
#> 7 Yes 14 (2.7) 13 (3.2)
#> OR (univariable) OR (multivariable) OR (multilevel
#> 3 - - -
#> 1 0.54 (0.32-0.92, p=0.023) 0.57 (0.34-0.98, p=0.041) 0.75 (0.39-1.44, p=0.382)
#> 2 0.75 (0.45-1.25, p=0.270) 0.81 (0.48-1.36, p=0.426) 1.03 (0.55-1.96, p=0.916)
#> 8 - - -
#> 9 0.98 (0.76-1.27, p=0.889) 0.98 (0.75-1.28, p=0.902) 0.80 (0.58-1.11, p=0.180)
#> 4 - - -
#> 5 1.25 (0.90-1.74, p=0.189) 1.25 (0.90-1.76, p=0.186) 1.23 (0.82-1.83, p=0.320)
#> 6 - - -
#> 7 1.18 (0.54-2.55, p=0.672) 1.12 (0.51-2.44, p=0.770) 1.03 (0.43-2.51, p=0.940)