Learn R Programming

finalfit

The finalfit package provides functions that help you quickly create elegant final results tables and plots when modelling in R. These can easily be exported as Word documents, PDFs, or html files.

Its design follows Hadley Wickham's tidy tool manifesto.

In addition, it provides functions for identifying and handling missing data, together with a number of functions to bootstrap simulate regression model results.

Installation

You can install finalfit from CRAN:

install.packages("finalfit")

It is recommended that this package is used together with dplyr which can be installed via:

install.packages("dplyr")

Documentation

The package documentation is maintained independently at finalfit.org.

Examples

See Get started and the All tables vignettes for extensive examples.

Crosstable / table 1

# Crosstable 
explanatory = c("age.factor", "sex.factor", "obstruct.factor")
dependent = 'mort_5yr'
colon_s %>%
  summary_factorlist(dependent, explanatory, 
  p=TRUE, add_dependent_label=TRUE) -> t1
knitr::kable(t1, align=c("l", "l", "r", "r", "r"))

Regression table

explanatory = c("age.factor", "sex.factor", 
  "obstruct.factor", "perfor.factor")
dependent = 'mort_5yr'
colon_s %>%
  finalfit(dependent, explanatory, metrics=TRUE) -> t2
knitr::kable(t2[[1]], row.names=FALSE, align=c("l", "l", "r", "r", "r", "r"))
knitr::kable(t2[[2]], row.names=FALSE, col.names="")

When exported to PDF:

Regression plots

explanatory = c("age.factor", "sex.factor", 
  "obstruct.factor", "perfor.factor")
dependent = 'mort_5yr'
colon_s %>%
  or_plot(dependent, explanatory)

Copy Link

Version

Install

install.packages('finalfit')

Monthly Downloads

2,104

Version

1.1.0

License

MIT + file LICENCE

Issues

Pull Requests

Stars

Forks

Maintainer

Ewen Harrison

Last Published

September 3rd, 2025

Functions in finalfit (1.1.0)

%$%

magrittr exposition pipe-operator
ff_newdata

Generate newdata for simulations
extract_labels

Extract variable labels and names
extract_fit

Extract model output to dataframe
ff_metrics

Generate common metrics for regression model results
ff_mode

Return the most frequent level in a factor
ff_merge

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

Label a variable
ff_parse_formula

Parse a formula to finalfit grammar
ff_relabel

Relabel variables in a data frame
ff_plot

Produce a table and plot
ff_interaction

Make an interaction variable and add to dataframe
ff_glimpse

Descriptive statistics for dataframe
ff_row_totals

Add row totals to summary_factorlist() output
ff_remove_ref

Remove regression reference level row from table
ff_permute

Permuate explanatory variables to produce multiple output tables for common regression models
ff_formula

Generate formula as character string
ff_expand

Summarise with mode and mean/median and expand given factors
ff_percent_only

Include only percentages for factors in summary_factorlist output
error_colon_fct_levels

Errors: colon in factor levels
glmmulti

Binomial logistic regression multivariable models: finalfit model wrapper
glmmulti_boot

Binomial logistic regression multivariable models with bootstrapped confidence intervals: finalfit model wrapper
hr_plot

Produce a hazard ratio table and plot
glmuni

Binomial logistic regression univariable models: finalfit model wrapper
is.survival

Test character describes survival object
labels_to_level

Labels to level
labels_to_column

Labels to column names
missing_df

Missing values data frame
missing_glimpse

Summary of missing values
missing_compare

Compare missing data
metrics_hoslem

Hosmer-Lemeshow goodness of fit test
finalfit-package

finalfit: Quickly create elegant final results tables and plots when modelling.
ff_stratify_helper

Help making stratified summary_factorlist tables
finalfit

Final output tables for common regression models
lmmulti

Linear regression multivariable models: finalfit model wrapper
fit2df

Extract model fit results to dataframe (generic): finalfit model extractors
remove_intercept

Remove intercept from model output
print.data.frame.ff

Print methods for finalfit data frames
lmmixed

Mixed effects linear regression models: finalfit model wrapper
ff_relabel_df

Relabel variables from data frame after tidyverse functions
missing_pattern

Characterise missing data for finalfit models
missing_pairs

Missing values pairs plot
missing_plot

Missing values occurrence plot
missing_predictorMatrix

Create predictorMatrix for use with mice
summary_mipo

Call to mice:::summary.mipo
lmuni

Linear regression univariable models: finalfit model wrapper
rm_duplicate_labels

Remove duplicate levels within summary_factorlist: finalfit helper function
remove_labels

Remove variable labels.
ff_remove_p

Remove p-value from output
%>%

Pipe operator
rm_duplicates

Remove duplicates and replace
variable_type

Determine type/class of a variable
rm_empty_block

Remove rows where all specified variables are missing
surv_plot

Plot survival curves with number-at-risk table
summary_factorlist

Summarise a set of factors (or continuous variables) by a dependent variable
plot_title

Label plot title
wcgs

Western Collaborative Group Study
svyglmuni

Univariable survey-weighted generalised linear models
svyglmmulti

Multivariable survey-weighted generalised linear models
summary_factorlist_stratified

Summarise a set of factors (or continuous variables) by a dependent variable
p_tidy

Round p-values but keep trailing zeros
glmmixed

Mixed effects binomial logistic regression models: finalfit model wrapper
format_n_percent

Format n and percent as a character
or_plot

Produce an odds ratio table and plot
summary_df

Summarise with mode for factors and mean/median for numeric variables
round_tidy

Round values but keep trailing zeros
%<>%

magrittr compound assignment pipe-operator
check_recode

Check accurate recoding of variables
boot_compare

Compare bootstrapped distributions
boot_predict

Bootstrap simulation for model prediction
coefficient_plot

Produce a coefficient table and plot
coxphmulti

Cox proprotional hazards multivariable models: finalfit model wrapper
coxphuni

Cox proprotional hazards univariable models: finalfit model wrapper
crrmulti

Competing risks multivariable regression: finalfit model wrapper
dependent_label

Make a label for the dependent variable
crruni

Competing risks univariable regression: finalfit model wrapper
extract_variable_label

Extract variable labels from dataframe
condense_fit

Condense model output dataframe for final tables
colon_s

Chemotherapy for Stage B/C colon cancer
ff_column_totals

Add column totals to summary_factorlist() output
catTestfisher

Deprecated catTest from Hmisc for reverse dependencies
ff_eval

Eval for `lm` and `glm` model wrappers