A function that takes the output from summary_factorlist(..., fit_id=TRUE) and merges with any number of model dataframes, usually produced with a model wrapper followed by the fit2df() function (see examples).

ff_merge(factorlist, fit2df_df, ref_symbol = "-", estimate_name = NULL)

finalfit_merge(factorlist, fit2df_df, ref_symbol = "-",
  estimate_name = NULL)

Arguments

factorlist

Output from summary_factorlist(..., fit_id=TRUE).

fit2df_df

Output from model wrappers followed by fit2df().

ref_symbol

Reference symbol for model reference levels, typically "-" or "1.0".

estimate_name

If you have chosen a new `estimate name` (e.g. "Odds ratio") when running a model wrapper (e.g. `glmuni`), then you need to pass this new name to `finalfit_merge` to generate correct table. Defaults to OR/HR/Coefficient

Value

Returns a dataframe of combined tables.

See also

Examples

library(finalfit) library(dplyr) data(colon_s) explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor") explanatory_multi = c("age.factor", "obstruct.factor") random_effect = "hospital" dependent = "mort_5yr" # Create separate tables colon_s %>% summary_factorlist(dependent, explanatory, fit_id=TRUE) -> example.summary 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)) -> example.final example.final
#> label levels Alive Died OR (univariable) #> 2 Age <40 years 31 (46.3) 36 (53.7) - #> 1 40-59 years 208 (61.4) 131 (38.6) 0.54 (0.32-0.92, p=0.023) #> 3 60+ years 272 (53.4) 237 (46.6) 0.75 (0.45-1.25, p=0.270) #> 8 Sex Female 243 (55.6) 194 (44.4) - #> 9 Male 268 (56.1) 210 (43.9) 0.98 (0.76-1.27, p=0.889) #> 4 Obstruction No 408 (56.7) 312 (43.3) - #> 5 Yes 89 (51.1) 85 (48.9) 1.25 (0.90-1.74, p=0.189) #> 6 Perforation No 497 (56.0) 391 (44.0) - #> 7 Yes 14 (51.9) 13 (48.1) 1.18 (0.54-2.55, p=0.672) #> OR (multivariable) OR (multilevel #> 2 - - #> 1 0.57 (0.34-0.98, p=0.041) 0.75 (0.39-1.44, p=0.382) #> 3 0.81 (0.48-1.36, p=0.426) 1.03 (0.55-1.96, p=0.916) #> 8 - - #> 9 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.76, p=0.186) 1.23 (0.82-1.83, p=0.320) #> 6 - - #> 7 1.12 (0.51-2.44, p=0.770) 1.03 (0.43-2.51, p=0.940)