Report correlations, regressions and summaries

Functions to create publication-ready tables for common analysis tasks

report_cat_vars()

Create a summary table for categorical variables and their relationship with a continuous outcome variable

report_cor_table()

Create a correlation table with summary statistics in APA style

report_lm_with_std()

Create a summary table comparing standardized and non-standardized linear models

report_polr_with_std()

Create a summary table comparing standardized and non-standardized proportional odd logistic regression models

Calculate correlation matrices

It can be surprisingly difficult to calculate correlation matrices, particularly when data is weighted or incomplete. These functions help and prepare data for report_cor_table()

cor_matrix()

Calculate correlation matrix with significance tests and descriptives

cor_matrix_mi()

Create a (weighted) correlation matrix from multiply imputed data

wtd_cor_matrix_mi()

Create a correlation matrix from multiply imputed data with weights

pcor_matrix()

Calculates a partial correlation matrix controlling for one or more variables

svy_cor_matrix()

Create a correlation matrix from survey data with summary statistics

tidy(<cor_matrix>)

Tidy a correlation matrix

tidy(<svy_cor_matrix>)

Tidy a survey-weighted correlation matrix

Formatters and reporting helpers

Functions to format numbers for statistical reporting and other helpers for statistical reporting

fmt_ci()

Format confidence interval based on the bounds

fmt_cor()

Format number as correlation coefficient

fmt_p()

Format p-value in line with APA standard (no leading 0)

fmt_pct()

Format fraction as percentage string

round_()

Round function that returns trailing zeroes

round_df()

Round all numeric columns in dataframe

sigstars()

Significance stars for p-values

get_pairwise_letters()

Get letters to indicate results of multiple comparisons/post-hoc tests

report_anova()

Report (model comparison) ANOVA tests

rename_cat_variables()

Rename variables and/or their levels

get_rename_tribbles()

Get code to generate tibbles to rename categorical variables and their levels

get_coef_rename_tribble()

Get code to rename model coefficients in summary tables

na_share()

Calculate share of NA-values in vector

cut_p()

Cut a continuous variable into given proportions

gt_apa_style()

Helper function to style gt-table in APA style

gt_add_plots()

Add plots into gt table column

plot_distributions()

Create distribution charts to show in descriptive table

tidy(<cor_matrix>)

Tidy a correlation matrix

tidy(<mira>)

Tidy multiple imputation models created with mice

tidy(<svy_cor_matrix>)

Tidy a survey-weighted correlation matrix

tidy(<tsR_std>)

Helper function to enable tidiers to be used on standardized models

glance(<mira>)

Glance a multiple imputation mice pooled object

Run and plot mediation models

Mediation models can be estimated with lavaan. These functions offer a simple interface and an integrated path from modeling to visualisation

run_mediation()

Conduct (parallel) mediation analysis

plot_mediation()

Plot mediation model with one or more mediators

plot_moderated_mediation()

Plot a moderated mediation model

Make and assess scales

Psychologists often use multiple items to measure a construct. These functions create scale scores and assess reliability (internal consistency)

make_scale()

Create a scale by calculating item mean and returns descriptives

make_scales()

Create multiple scales by calculating item means and return descriptives

make_scale_mi()

Create a scale based on multiple imputation at item level

spearman_brown()

Calculate Spearman-Brown reliability for two-item scale

Statistical tests

Some functions to facilitate running common tests with less common requirements

lm_std()

lm() with standardised continuous variables

polr_std()

polr() with standardised continuous variables

t_test_mi()

t-test() on multiply-imputed data (accepts survey weights)

paired_t_test_d()

Paired t.test with Cohen's d

pairwise_t_tests()

Pairwise t-tests() returned in tidy dataframe

svy_pairwise_t_test()

Pairwise t.tests with effect sizes and survey weights

pairwise_t_test_mi()

Pairwise t-tests() on multiply-imputed data (accepts survey weights)

mira.lm_F_test()

Report F-test for significance of multiply imputed lm models

Survey functions

Functions to work with survey data

svy_cohen_d_pair()

t.test for survey object with Cohen's d

svy_cor_matrix()

Create a correlation matrix from survey data with summary statistics

svy_make_scale()

Create scale by calculating item mean and returns descriptives for srvyr objects

svy_miss_var_summary()

Create overview over missing data in survey object

svy_pairwise_t_test()

Pairwise t.tests with effect sizes and survey weights

Demo datasets

ess_health

Sample data: health data from the European Social Survey Wave 7

WVS

Sample data: World Values Survey

Workflow functions

Miscellaneous functions that can improve your workflow, from setting up structured analysis projects to using the clipboard

setup_analysis_project()

Set up analysis project folder and script files

clip_excel()

Copy data to clipboard to paste into Excel

dump_to_clip()

Dump objects to clipboard (to transfer them between R sessions)

run_and_format()

Run a code snippet and copy formatted code and output to clipboard

to_tribble()

Convert a tibble/dataframe to tribble code

line_to_vector()

Turn line of items separated by whitespace into vector or code for c()

ggsave_show()

Save ggplot-graph and show in folder

dummy_code()

Dummy-code variable

na_ifs()

Set variable to NA when it has specific values

na_when()

Set variable to NA based on conditions

Miscellaneous

timesaveR-package timesaveR

Functions to Accelerate (Academic) Data Analysis and Reporting

knit_print.timesaveR_raw_html()

Knitr S3 method to print tables

print(<timesaveR_raw_html>)

Renders HTML code for Viewer pane

paste_()

Paste arguments while ignoring NAs