Format Output

Format data frames as a flextable for reporting

format_flextable()

Standard options used to format a flextable

format_tableby()

Generate a formatted flextable from a tableby object

format_modelsum()

Generate a formatted flextable from a modelsum object

format_pbold()

Format a column

add_footer()

Add a formatted footer to a flextable

add_table()

Add tables and titles to a word document

Format Contents

Additional functions to help format data frames, strings, and vectors for reports

move_to_last() move_to_first()

Move a column to the beginning or end of a data frame

sort_by_label()

Sort the columns of a data frame by it's labels (alphabetically)

add_total_column()

Add a total column to a tbl

format_p()

Format a column of p-values

str_to_firstup()

Capitalize the first character of a string

unfill_vec()

Unfill a vector

countpct()

Summarize two columns as N (%)

nrange()

Summarize three columns as N (low, high)

split_nrange()

Split character vector of N (low, high) into three columns

percent_to_numeric()

Convert a formatted percent to a numeric

in_row_headers()

Add header rows within a column for values that repeat.

polish()

Tidy and put the finishing touches on a model output

Project Management

Helpful function to set up and maintain a new project

knitthis()

Knit the Rmd file that is currently open

clean_wd()

Move all html, pdf, and docx files to an output directory

rm_all()

Remove all data from the global environment

Other

Other helpful functions

missing_tbl()

Generate a table of "missingness"

all_identical() any_identical()

Check if any number of values are identical

all_unique()

Check if all values are unique

coalesce_rows()

Coalesce columns of a data frame

calc_age()

Calculate age

surv_time()

Calculate time variable for survival analysis

non_na()

Return indexes of values that are (or are not) NA

vec_to_regex()

Convert a vector to a regular expression

label_df()

Create a data frame with columns for variables and variable labels

pct_change()

Calculate the percent change between two values or vectors of values

Models

Additional model outputs

modelsum_cox()

Univariable Cox regression Table

modelsum_km()

Kaplan-Meier Table

Data

Constants built into Pmisc

days

Days of week

days.abb

Three-letter abbreviations for days of week