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

License

MIT + file LICENCE

Issues

Pull Requests

Stars

Forks

Maintainer

Ewen Harrison

Last Published

July 3rd, 2020

Functions in finalfit (1.0.2)

colon_s

Chemotherapy for Stage B/C colon cancer
boot_compare

Compare bootstrapped distributions
check_recode

Check accurate recoding of variables
coxphuni

Cox proprotional hazards univariable models: finalfit model wrapper
coefficient_plot

Produce a coefficient table and plot
coxphmulti

Cox proprotional hazards multivariable models: finalfit model wrapper
%<>%

magrittr compound assignment pipe-operator
catTestfisher

Deprecated catTest from Hmisc for reverse dependencies
boot_predict

Bootstrap simulation for model prediction
crrmulti

Competing risks multivariable regression: finalfit model wrapper
condense_fit

Condense model output dataframe for final tables
%$%

magrittr exposition pipe-operator
ff_column_totals

Add column totals to summary_factorlist() output
dependent_label

Make a label for the dependent variable
ff_merge

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

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

Errors: colon in factor levels
extract_fit

Extract model output to dataframe
ff_percent_only

ff_newdata

Generate newdata for simulations
extract_labels

Extract variable labels and names
extract_variable_label

Extract variable labels from dataframe
ff_interaction

Make an interaction variable and add to dataframe
crruni

Competing risks univariable regression: finalfit model wrapper
ff_glimpse

Descriptive statistics for dataframe
fit2df

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

Generate formula as character string
format_n_percent

Format n and percent as a character
ff_plot

Produce a table and plot
ff_permute

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

Add row totals to summary_factorlist() output
glmmulti_boot

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

Label a variable
ff_metrics

Generate common metrics for regression model results
ff_stratify_helper

Help making stratified summary_factorlist tables
hr_plot

Produce a hazard ratio table and plot
is.survival

Test character describes survival object
ff_relabel

Relabel variables in a data frame
glmuni

Binomial logistic regression univariable models: finalfit model wrapper
lmmulti

Linear regression multivariable models: finalfit model wrapper
lmmixed

Mixed effects linear regression models: finalfit model wrapper
missing_predictorMatrix

Create predictorMatrix for use with mice
missing_compare

Compare missing data
missing_df

Missing values data frame
finalfit-package

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

Linear regression univariable models: finalfit model wrapper
plot_title

Label plot title
ff_relabel_df

Relabel variables from data frame after tidyverse functions
or_plot

Produce an odds ratio table and plot
summary_factorlist

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

Multivariable survey-weighted generalised linear models
round_tidy

Round values but keep trailing zeros
svyglmuni

Univariable survey-weighted generalised linear models
rm_duplicate_labels

rm_duplicates

Remove duplicates and replace
glmmixed

Mixed effects binomial logistic regression models: finalfit model wrapper
glmmulti

Binomial logistic regression multivariable models: finalfit model wrapper
p_tidy

Round p-values but keep trailing zeros
%>%

Pipe operator
metrics_hoslem

Hosmer-Lemeshow goodness of fit test
ff_remove_p

Remove p-value from output
wcgs

Western Collaborative Group Study
ff_remove_ref

Remove regression reference level row from table
labels_to_column

Labels to column names
variable_type

Determine type/class of a variable
missing_pairs

Missing values pairs plot
missing_glimpse

Summary of missing values
labels_to_level

Labels to level
remove_intercept

Remove intercept from model output
remove_labels

Remove variable labels.
surv_plot

Plot survival curves with number-at-risk table
summary_mipo

Call to mice:::summary.mipo
finalfit

Final output tables for common regression models
missing_plot

Missing values occurence plot
missing_pattern

Characterise missing data for finalfit models
print.data.frame.ff

Print methods for finalfit data frames