Learn R Programming

finalfit (version 0.8.9)

ff_merge: Merge a summary_factorlist() table with any number of model results tables.

Description

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).

Usage

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

summary_factorlist fit2df

Examples

Run this code
# NOT RUN {
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

colon_s %>%
	glmmulti(dependent, explanatory) %>%
	fit2df(estimate_suffix=" (multivariable)") -> example.multivariable

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
# }

Run the code above in your browser using DataLab