Learn R Programming

⚠️There's a newer version (1.0.8) of this package.Take me there.

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 getting 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,872

Version

1.0.6

License

MIT + file LICENCE

Issues

Pull Requests

Stars

Forks

Maintainer

Ewen Harrison

Last Published

January 14th, 2023

Functions in finalfit (1.0.6)

extract_variable_label

Extract variable labels from dataframe
ff_column_totals

Add column totals to summary_factorlist() output
%$%

magrittr exposition pipe-operator
error_colon_fct_levels

Errors: colon in factor levels
dependent_label

Make a label for the dependent variable
crrmulti

Competing risks multivariable regression: finalfit model wrapper
crruni

Competing risks univariable regression: finalfit model wrapper
extract_labels

Extract variable labels and names
extract_fit

Extract model output to dataframe
ff_eval

Eval for `lm` and `glm` model wrappers
ff_merge

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

Make an interaction variable and add to dataframe
ff_label

Label a variable
ff_percent_only

Include only percentages for factors in summary_factorlist output
ff_permute

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

Generate common metrics for regression model results
ff_formula

Generate formula as character string
ff_glimpse

Descriptive statistics for dataframe
ff_parse_formula

Parse a formula to finalfit grammar
ff_newdata

Generate newdata for simulations
ff_plot

Produce a table and plot
ff_relabel_df

Relabel variables from data frame after tidyverse functions
finalfit

Final output tables for common regression models
ff_stratify_helper

Help making stratified summary_factorlist tables
ff_relabel

Relabel variables in a data frame
finalfit-package

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

Remove regression reference level row from table
ff_row_totals

Add row totals to summary_factorlist() output
glmmulti_boot

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

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

Binomial logistic regression multivariable models: finalfit model wrapper
labels_to_level

Labels to level
lmmixed

Mixed effects linear regression models: finalfit model wrapper
labels_to_column

Labels to column names
is.survival

Test character describes survival object
lmuni

Linear regression univariable models: finalfit model wrapper
lmmulti

Linear regression multivariable models: finalfit model wrapper
glmmixed

Mixed effects binomial logistic regression models: finalfit model wrapper
format_n_percent

Format n and percent as a character
missing_glimpse

Summary of missing values
ff_remove_p

Remove p-value from output
rm_duplicates

Remove duplicates and replace
glmuni

Binomial logistic regression univariable models: finalfit model wrapper
missing_df

Missing values data frame
metrics_hoslem

Hosmer-Lemeshow goodness of fit test
hr_plot

Produce a hazard ratio table and plot
missing_predictorMatrix

Create predictorMatrix for use with mice
missing_plot

Missing values occurrence plot
rm_empty_block

Remove rows where all specified variables are missing
remove_intercept

Remove intercept from model output
missing_compare

Compare missing data
print.data.frame.ff

Print methods for finalfit data frames
surv_plot

Plot survival curves with number-at-risk table
svyglmmulti

Multivariable survey-weighted generalised linear models
remove_labels

Remove variable labels.
wcgs

Western Collaborative Group Study
svyglmuni

Univariable survey-weighted generalised linear models
variable_type

Determine type/class of a variable
missing_pattern

Characterise missing data for finalfit models
missing_pairs

Missing values pairs plot
plot_title

Label plot title
%>%

Pipe operator
round_tidy

Round values but keep trailing zeros
summary_factorlist

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

Remove duplicate levels within summary_factorlist: finalfit helper function
summary_factorlist_stratified

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

Produce an odds ratio table and plot
summary_mipo

Call to mice:::summary.mipo
p_tidy

Round p-values but keep trailing zeros
catTestfisher

Deprecated catTest from Hmisc for reverse dependencies
coxphmulti

Cox proprotional hazards multivariable models: finalfit model wrapper
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
coxphuni

Cox proprotional hazards univariable models: finalfit model wrapper
condense_fit

Condense model output dataframe for final tables
colon_s

Chemotherapy for Stage B/C colon cancer
%<>%

magrittr compound assignment pipe-operator