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

License

MIT + file LICENCE

Issues

Pull Requests

Stars

Forks

Maintainer

Ewen Harrison

Last Published

November 16th, 2023

Functions in finalfit (1.0.7)

error_colon_fct_levels

Errors: colon in factor levels
ff_merge

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

Help making stratified summary_factorlist tables
%$%

magrittr exposition pipe-operator
ff_relabel_df

Relabel variables from data frame after tidyverse functions
ff_remove_p

Remove p-value from output
ff_remove_ref

Remove regression reference level row from table
ff_row_totals

Add row totals to summary_factorlist() output
ff_label

Label a variable
ff_parse_formula

Parse a formula to finalfit grammar
ff_newdata

Generate newdata for simulations
ff_interaction

Make an interaction variable and add to dataframe
ff_plot

Produce a table and plot
extract_fit

Extract model output to dataframe
finalfit

Final output tables for common regression models
fit2df

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

Chemotherapy for Stage B/C colon cancer
ff_metrics

Generate common metrics for regression model results
format_n_percent

Format n and percent as a character
ff_relabel

Relabel variables in a data frame
glmmixed

Mixed effects binomial logistic regression models: finalfit model wrapper
ff_percent_only

Include only percentages for factors in summary_factorlist output
is.survival

Test character describes survival object
finalfit-package

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

Missing values pairs plot
metrics_hoslem

Hosmer-Lemeshow goodness of fit test
labels_to_level

Labels to level
lmmixed

Mixed effects linear regression models: finalfit model wrapper
glmuni

Binomial logistic regression univariable models: finalfit model wrapper
missing_pattern

Characterise missing data for finalfit models
glmmulti

Binomial logistic regression multivariable models: finalfit model wrapper
missing_compare

Compare missing data
missing_plot

Missing values occurrence plot
rm_empty_block

Remove rows where all specified variables are missing
ff_permute

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

Pipe operator
labels_to_column

Labels to column names
hr_plot

Produce a hazard ratio table and plot
glmmulti_boot

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

Remove duplicates and replace
missing_predictorMatrix

Create predictorMatrix for use with mice
lmmulti

Linear regression multivariable models: finalfit model wrapper
variable_type

Determine type/class of a variable
plot_title

Label plot title
lmuni

Linear regression univariable models: finalfit model wrapper
svyglmuni

Univariable survey-weighted generalised linear models
print.data.frame.ff

Print methods for finalfit data frames
wcgs

Western Collaborative Group Study
missing_df

Missing values data frame
round_tidy

Round values but keep trailing zeros
summary_factorlist

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

Remove intercept from model output
surv_plot

Plot survival curves with number-at-risk table
remove_labels

Remove variable labels.
rm_duplicate_labels

Remove duplicate levels within summary_factorlist: finalfit helper function
svyglmmulti

Multivariable survey-weighted generalised linear models
missing_glimpse

Summary of missing values
summary_factorlist_stratified

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

Call to mice:::summary.mipo
or_plot

Produce an odds ratio table and plot
p_tidy

Round p-values but keep trailing zeros
%<>%

magrittr compound assignment pipe-operator
coefficient_plot

Produce a coefficient table and plot
check_recode

Check accurate recoding of variables
coxphuni

Cox proprotional hazards univariable models: finalfit model wrapper
boot_compare

Compare bootstrapped distributions
boot_predict

Bootstrap simulation for model prediction
coxphmulti

Cox proprotional hazards multivariable models: finalfit model wrapper
ff_column_totals

Add column totals to summary_factorlist() output
extract_variable_label

Extract variable labels from dataframe
crruni

Competing risks univariable regression: finalfit model wrapper
dependent_label

Make a label for the dependent variable
condense_fit

Condense model output dataframe for final tables
catTestfisher

Deprecated catTest from Hmisc for reverse dependencies
extract_labels

Extract variable labels and names
ff_eval

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

Competing risks multivariable regression: finalfit model wrapper
ff_glimpse

Descriptive statistics for dataframe
ff_formula

Generate formula as character string