Package: finalfit 1.1.1

Ewen Harrison

finalfit: Quickly Create Elegant Regression Results Tables and Plots when Modelling

Generate regression results tables and plots in final format for publication. Explore models and export directly to PDF and 'Word' using 'RMarkdown'.

Authors:Ewen Harrison [aut, cre], Tom Drake [aut], Riinu Pius [aut]

finalfit_1.1.1.tar.gz
finalfit_1.1.1.zip(r-4.7)finalfit_1.1.1.zip(r-4.6)finalfit_1.1.1.zip(r-4.5)
finalfit_1.1.1.tgz(r-4.6-any)finalfit_1.1.1.tgz(r-4.5-any)
finalfit_1.1.1.tar.gz(r-4.7-any)finalfit_1.1.1.tar.gz(r-4.6-any)
finalfit_1.1.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
finalfit/json (API)

# Install 'finalfit' in R:
install.packages('finalfit', repos = c('https://ewenharrison.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/ewenharrison/finalfit/issues

Datasets:
  • colon_s - Chemotherapy for Stage B/C colon cancer
  • wcgs - Western Collaborative Group Study

On CRAN:

Conda:

11.86 score 276 stars 1 packages 1.4k scripts 2.6k downloads 26 mentions 95 exports 77 dependencies

Last updated from:8c6e16214d. Checks:7 NOTE, 2 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64NOTE242
source / vignettesOK366
linux-release-x86_64NOTE278
macos-release-arm64NOTE173
macos-oldrel-arm64NOTE192
windows-develNOTE205
windows-releaseNOTE210
windows-oldrelNOTE204
wasm-releaseOK203

Exports:%<>%%>%%$%boot_compareboot_predictcatTestfishercheck_recodecoefficient_plotcondense_fitcoxphmulticoxphunicrrmulticrrunidependent_labelextract_fitextract_labelsextract_variable_labelff_column_totalsff_expandff_formulaff_glimpseff_interactionff_labelff_mergeff_metricsff_modeff_newdataff_parse_formulaff_percent_onlyff_permuteff_plotff_relabelff_relabel_dfff_remove_pff_remove_refff_row_totalsff_stratify_helperfinalfitfinalfit_column_totalsfinalfit_expandfinalfit_formulafinalfit_glimpsefinalfit_interactionfinalfit_labelfinalfit_mergefinalfit_modefinalfit_newdatafinalfit_percent_onlyfinalfit_permutefinalfit_plotfinalfit_relabelfinalfit_relabel_dffinalfit_remove_pfinalfit_remove_reffinalfit_row_totalsfinalfit.coxphfinalfit.glmfinalfit.lmfit2dfformat_n_percentglmmixedglmmultiglmmulti_bootglmunihr_plotis.survivallabels_to_columnlabels_to_levellmmixedlmmultilmunimetrics_hoslemmissing_comparemissing_dfmissing_glimpsemissing_pairsmissing_patternmissing_plotmissing_predictorMatrixor_plotp_tidyplot_titleremove_interceptremove_labelsrm_duplicate_labelsrm_duplicatesrm_empty_blockround_tidysummary_dfsummary_factorlistsummary_factorlist_stratifiedsurv_plotsvyglmmultisvyglmunivariable_type

Dependencies:backportsbdsmatrixbitbit64bootbroomclicliprcodetoolscowplotcpp11crayondplyrfarverforcatsforeachgenericsGGallyggplot2ggstatsglmnetgluegtablehavenhmsisobanditeratorsjomolabelinglatticelifecyclelme4magrittrMASSMatrixmiceminqamitmlnlmenloptrnnetnumDerivordinalpanpatchworkpillarpkgconfigprettyunitspROCprogresspurrrR6rbibutilsRColorBrewerRcppRcppEigenRdpackreadrreformulasrlangrpartS7scalesshapestringistringrsurvivaltibbletidyrtidyselecttzdbucminfutf8vctrsviridisLitevroomwithr

All plots examples
1 Odds ratio plots | 1.01 Standard odds ratio plot (forest plot) | 1.02 Mixed effects odds ratio plot (forest plot) | 1.03 Plotting a subset of variables from a full model | 1.04 Plotting from model object | 1.05 Plotting univariable models | 1.06 Confidence interval type | 1.07 Remove reference levels | 1.08 Manually specifiy x-axis breaks | 1.09 Adjust table column spacing | 1.10 Adjust or remove dependent variable label | 1.11 Add dependent variable label prefix | 1.12 Adjust or remove dependent variable label suffix | 1.13 Adjust table text size | 1.14 Adjust title text size | 1.15 Add plot options | 1.16 Add other options | 2 Hazard ratio plots | 2.01 Standard hazard ratio plot | 3 Coefficient plots | 3.01 Standard coefficient plots | 4 Wrapper for all plot types | 5 Kaplan Meier plots | 5.1 Standard KM plot | 5.2 Adjust using options | 6 Missing data plots

Last update: 2025-09-03
Started: 2023-01-15

All tables examples
1 Cross tables | 1.01 Default | 1.02 Add or edit variable labels | 1.03 P-value for hypothesis test | 1.04 With Fisher's exact test | 1.05 Parametric explanatory variables | 1.06 Non-parametric explanatory variables | 1.07 Select specific non-parametric variables | 1.08 Missing values for the explanatory variables | 1.09 Pass missing values to statistical tests | 1.10 Row proportions (rather than column) | 1.11 Total column | 1.12 Row totals with missing | 1.13 Row totals without missing | 1.14 Row totals with user-specified column names | 1.15 Order a variable by total | 1.17 Add column totals | 1.18 Add column totals without proportion. | 1.19 Add column totals with user-specified row name and prefix. | 1.20 Label with dependent name | 1.21 Dependent variable with any number of factor levels supported | 1.22 Missing data in the dependent | 1.23 Directly include missing data in dependent | 1.24 Summarise complete cases | 1.25 Actively dropping missing data (and tidyverse functions that strip attributes) | 1.26 Explanatory variable defaults to factor when ≤5 distinct values | 1.27 Keep as continous variable when ≤5 distinct values | 1.28 Stratified crosstables | 1.29 Digits / decimal places | 1.30 Weighted tables | 2 Model tables with finalfit() | 2.01 Default | 2.02 Hide reference levels | 2.03 Model metrics | 2.04 Model metrics can be applied to all supported base models | 2.05 Reduced model | 2.06 Include all models | 2.06 Interactions | 2.07 Interactions: create interaction variable with two factors | 2.08 Dependent name | 2.09 Estimate name | 2.10 Digits / decimal places | 2.11 Confidence interval type | 2.12 Confidence interval level | 2.13 Confidence interval separation | 2.14 Robust standard errors / confidence intervals | 2.15 Remove p-value | 2.16 Mixed effects random-intercept model | 2.16b Mixed effects random-intercept model with univariable estimates including random effects | 2.17 Mixed effects random-slope model | 2.18 Mixed effects random-slope model directly from lme4 | 2.19 Exclude all missing data in final model from univariable analyses | 2.20 Linear regression | 2.21 Mixed effects random-intercept linear regression | 2.22 Mixed effects random-slope linear regression | 2.23 Cox proportional hazards model (survival / time to event) | 2.24 Cox proportional hazards model: change dependent label | 3 Model tables manually using ff_merge() | 3.1 Basic table | 3.2 Complex table (all in single pipe) | 3.3 Other GLM models | Poisson | Gamma | 3.4 Weighted regression | 3.5 Using base R functions | 3.6 Edit table rows | 3.7 Base model + individual explanatory variables | 4 Support for complex survey structures via library(survey) | 4.1 Linear regression | 4.2 Binomial example

Last update: 2024-07-23
Started: 2019-02-25

Bootstrap simulation for model prediction
Create new dataframe of explanatory variable levels | ff_expand() for creating new data frame | Run bootstrap simulations of model predictions | Output to Word, PDF, and html via RMarkdown | Make comparisons | What is not included? | Plotting

Last update: 2024-07-23
Started: 2018-09-11

Missing data
Some confusing terminology | Missing completely at random (MCAR) | Missing at random (MAR) | Missing not at random (MNAR) | 1. Ensure your data are coded correctly: ff_glimpse | Example scenario | 2. Identify missing values in each variable: missing_plot | 3. Look for patterns of missingness: missing_pattern | Make sure you include missing data in demographics tables | 4. Check for associations between missing and observed data: missing_pairs | missing_compare | For those who like an omnibus test | 5. Decide how to handle missing data | MCAR, MAR, or MNAR | MCAR vs MAR | Common solution | Other considerations | MNAR vs MAR | Where to next

Last update: 2023-11-06
Started: 2018-09-11

Getting started
Installation and Documentation | Main Features | 1. Summarise variables/factors by a categorical variable | 2. Summarise regression model results in final table format | Logistic regression: glm() | Logistic regression with reduced model: glm() | Mixed effects logistic regression: lme4::glmer() | Cox proportional hazards: survival::coxph() | Add common model metrics to output | Combine multiple models into single table | Bayesian logistic regression: with stan | 3. Summarise regression model results in plot | OR plot | HR plot | Kaplan-Meier survival plots | Notes

Last update: 2021-06-18
Started: 2018-09-10

Time-to-event (Survival)
Background | Installation | Dataset | Get data and check | Death status | Time and censoring | Recode | Kaplan-Meier survival estimator | KM analysis for whole cohort | Model | Life table | Kaplan Meier plot | Cox-proportional hazards regression | Univariable and multivariable models | Reduced model | Testing for proportional hazards | Stratified models | Correlated groups of observations | Hazard ratio plot | Competing risks regression | Summary

Last update: 2020-01-29
Started: 2019-07-16

Exporting tables and plots
Explore data | Demographics table | Logistic regression table | Odds ratio plot | MS Word via knitr/R Markdown | Create Word template file | PDF via knitr/R Markdown

Last update: 2019-04-24
Started: 2018-09-11

Preparing data for finalfit
Read data | Column types | Continuous data | Categorical data | Dates and times | Check data | Specify factors

Last update: 2019-02-15
Started: 2019-02-15

Readme and manuals

Help Manual

Help pageTopics
Compare bootstrapped distributionsboot_compare
Bootstrap simulation for model predictionboot_predict
Check accurate recoding of variablescheck_recode
Produce a coefficient table and plotcoefficient_plot
Chemotherapy for Stage B/C colon cancercolon_s
Cox proprotional hazards multivariable models: 'finalfit' model wrappercoxphmulti
Cox proprotional hazards univariable models: 'finalfit' model wrappercoxphuni
Competing risks multivariable regression: 'finalfit' model wrappercrrmulti
Competing risks univariable regression: 'finalfit' model wrappercrruni
Make a label for the dependent variabledependent_label
Extract variable labels from dataframeextract_variable_label
Add column totals to 'summary_factorlist()' outputff_column_totals finalfit_column_totals
Summarise with mode and mean/median and expand given factorsff_expand finalfit_expand
Generate formula as character stringff_formula finalfit_formula
Descriptive statistics for dataframeff_glimpse finalfit_glimpse
Make an interaction variable and add to dataframeff_interaction finalfit_interaction
Label a variableff_label finalfit_label
Merge a 'summary_factorlist()' table with any number of model results tables.ff_merge finalfit_merge
Generate common metrics for regression model resultsff_metrics ff_metrics.coxph ff_metrics.coxphlist ff_metrics.glm ff_metrics.glmerMod ff_metrics.glmlist ff_metrics.lm ff_metrics.lmerMod ff_metrics.lmlist
Return the most frequent level in a factorff_mode finalfit_mode
Generate newdata for simulationsff_newdata finalfit_newdata
Parse a formula to finalfit grammarff_parse_formula
Include only percentages for factors in 'summary_factorlist' outputff_percent_only finalfit_percent_only
Permuate explanatory variables to produce multiple output tables for common regression modelsff_permute finalfit_permute
Produce a table and plotff_plot finalfit_plot
Relabel variables in a data frameff_relabel finalfit_relabel
Relabel variables from data frame after tidyverse functionsff_relabel_df finalfit_relabel_df
Remove p-value from outputff_remove_p finalfit_remove_p
Remove regression reference level row from tableff_remove_ref finalfit_remove_ref
Add row totals to 'summary_factorlist()' outputff_row_totals finalfit_row_totals
Help making stratified summary_factorlist tablesff_stratify_helper
Final output tables for common regression modelsfinalfit finalfit.coxph finalfit.glm finalfit.lm
Extract model fit results to dataframe (generic): 'finalfit' model extractorsfit2df fit2df.coxme fit2df.coxph fit2df.coxphlist fit2df.crr fit2df.crrlist fit2df.glm fit2df.glmboot fit2df.glmerMod fit2df.glmlist fit2df.lm fit2df.lmerMod fit2df.lmlist fit2df.mipo fit2df.stanfit fit2df.svyglmlist
Format n and percent as a characterformat_n_percent
Mixed effects binomial logistic regression models: 'finalfit' model wrapperglmmixed
Binomial logistic regression multivariable models: 'finalfit' model wrapperglmmulti
Binomial logistic regression multivariable models with bootstrapped confidence intervals: 'finalfit' model wrapperglmmulti_boot
Binomial logistic regression univariable models: 'finalfit' model wrapperglmuni
Produce a hazard ratio table and plothr_plot
Labels to column nameslabels_to_column
Labels to levellabels_to_level
Mixed effects linear regression models: 'finalfit' model wrapperlmmixed
Linear regression multivariable models: 'finalfit' model wrapperlmmulti
Linear regression univariable models: 'finalfit' model wrapperlmuni
Hosmer-Lemeshow goodness of fit testmetrics_hoslem
Compare missing datamissing_compare
Summary of missing valuesmissing_glimpse
Missing values pairs plotmissing_pairs
Characterise missing data for 'finalfit' modelsmissing_pattern
Missing values occurrence plotmissing_plot
Create predictorMatrix for use with micemissing_predictorMatrix
Produce an odds ratio table and plotor_plot
Round p-values but keep trailing zerosp_tidy
Remove duplicates and replacerm_duplicates
Remove rows where all specified variables are missingrm_empty_block
Round values but keep trailing zerosround_tidy
Summarise with mode for factors and mean/median for numeric variablessummary_df
Summarise a set of factors (or continuous variables) by a dependent variablesummary_factorlist
Summarise a set of factors (or continuous variables) by a dependent variablesummary_factorlist_stratified
Plot survival curves with number-at-risk tablesurv_plot
Multivariable survey-weighted generalised linear modelssvyglmmulti
Univariable survey-weighted generalised linear modelssvyglmuni
Western Collaborative Group Studywcgs