Giter VIP home page Giter VIP logo

timesaver's Introduction

timesaveR

R-CMD-check Codecov test coverage Lifecycle:Maturing

This package aims to speed up research projects in social psychology (and related fields). For that, it primarily includes some functions that help lay the groundwork and others that facilitate the reporting of results.

Among others, the package can help with the following:

  • Creating scales, including reverse-coding and reporting their internal consistency,
  • Creating correlation tables in APA style, including descriptive statistics and confidence intervals, and an option to use survey weights, multiple imputation or full-information maximum-likelihood estimation
  • Creating regression tables comparing standardised and non-standardised regression coefficients, and comparing the F-change between two nested models
  • Formatting numbers for statistical reporting, including rounding with trailing zeros, or displaying numbers as p-values or as confidence intervals
  • Data entry and transfer, for quick interactive use. This includes splitting clipboard content into vectors, converting tibbles to tribble code, or obtaining nicely formatted code and results to paste into another application

Why use this package?

There are many packages that support data analysis and reporting. For instance, the psych package offers functions to create scales, while the modelsummary package offers options to create customisable tables in a wide variety of output format. They power many of the functions offered here ‘under the hood.’

apa and papaja are two packages that directly support the reporting of results in APA style - they can complement this package well. However, none of the existing offered quite what we needed. This package

  • takes an end-to-end view of the data analysis process, streamlining time-consuming steps at various stages
  • offers analysis templates that make it easy to get started, particularly for R novices,
  • prioritises publication-readiness and good reporting practices over customisability in creating tables and charts
  • integrates with the tidyverse by supporting tidy evaluation and returning tibbles where possible

Installation

You can install timesaveR from GitHub with the command below. If you do not have the remotes-package installed, run install.packages("remote") first.

remotes::install_github('lukaswallrich/timesaveR')

Get started

There are many functions in the package, and we will create vignettes detailing various use cases. However, the following can give you an initial flavor. The examples use data from the European Social Survey Wave 7 (2014). Here, I ignore survey weights. However, the package offers similar functions for analysing weighted survey data, which are explained in the survey data vignette.

Load the package

(I also load dplyr since that is the recommended usage - of course, there are base R alternatives for all of the steps.)

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(timesaveR)
#> Note re timesaveR: Many functions in this package are alpha-versions - please treat results with care and report bugs and desired features.

Create scales

Let’s create scales for health behaviours and depressive symptoms, each including some reverse coding.

scales <- list(
  depression = c("fltdpr", "flteeff", "slprl", "wrhpp", "fltlnl", 
                 "enjlf", "fltsd", "cldgng"),
  healthy_eating = c("etfruit", "eatveg")
  )
  
scales_reverse <- list(
  depression = c("wrhpp", "enjlf"),
  healthy_eating = c("etfruit", "eatveg")
)

scales <- make_scales(ess_health, items = scales, reversed = scales_reverse)
#> The following scales will be calculated with specified reverse coding: depression, healthy_eating

#Check descriptives, including reliability
scales$descriptives
#> # A tibble: 2 × 10
#>   Scale      n_items reliability reliability_method  mean    SD reversed rev_min
#>   <chr>        <int>       <dbl> <chr>              <dbl> <dbl> <chr>      <dbl>
#> 1 depression       8       0.802 cronbachs_alpha     1.67 0.484 wrhpp e…       1
#> 2 healthy_e…       2       0.658 spearman_brown      4.97 1.11  etfruit…       1
#> # ℹ 2 more variables: rev_max <dbl>, text <chr>

#Add scale scores to dataset
ess_health <- bind_cols(ess_health, scales$scores)

Report correlations and descriptive statistics

Next, we are often interested in descriptive statistics, variable distributions and correlations.

ess_health %>% select(agea, health, depression, healthy_eating) %>% 
    cor_matrix() %>% report_cor_table()
<style>#uuaxumjvmz table { font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

#uuaxumjvmz thead, #uuaxumjvmz tbody, #uuaxumjvmz tfoot, #uuaxumjvmz tr, #uuaxumjvmz td, #uuaxumjvmz th { border-style: none; }

#uuaxumjvmz p { margin: 0; padding: 0; }

#uuaxumjvmz .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }

#uuaxumjvmz .gt_caption { padding-top: 4px; padding-bottom: 4px; }

#uuaxumjvmz .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }

#uuaxumjvmz .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }

#uuaxumjvmz .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }

#uuaxumjvmz .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; }

#uuaxumjvmz .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }

#uuaxumjvmz .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }

#uuaxumjvmz .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }

#uuaxumjvmz .gt_column_spanner_outer:first-child { padding-left: 0; }

#uuaxumjvmz .gt_column_spanner_outer:last-child { padding-right: 0; }

#uuaxumjvmz .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }

#uuaxumjvmz .gt_spanner_row { border-bottom-style: hidden; }

#uuaxumjvmz .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }

#uuaxumjvmz .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }

#uuaxumjvmz .gt_from_md > :first-child { margin-top: 0; }

#uuaxumjvmz .gt_from_md > :last-child { margin-bottom: 0; }

#uuaxumjvmz .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: none; border-top-width: 1px; border-top-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }

#uuaxumjvmz .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }

#uuaxumjvmz .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }

#uuaxumjvmz .gt_row_group_first td { border-top-width: 2px; }

#uuaxumjvmz .gt_row_group_first th { border-top-width: 2px; }

#uuaxumjvmz .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }

#uuaxumjvmz .gt_first_summary_row { border-top-style: none; border-top-color: #D3D3D3; }

#uuaxumjvmz .gt_first_summary_row.thick { border-top-width: 2px; }

#uuaxumjvmz .gt_last_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }

#uuaxumjvmz .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }

#uuaxumjvmz .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: none; border-top-width: 6px; border-top-color: #D3D3D3; }

#uuaxumjvmz .gt_last_grand_summary_row_top { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }

#uuaxumjvmz .gt_striped { background-color: rgba(128, 128, 128, 0.05); }

#uuaxumjvmz .gt_table_body { border-top-style: solid; border-top-width: 1px; border-top-color: #000000; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; }

#uuaxumjvmz .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }

#uuaxumjvmz .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }

#uuaxumjvmz .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }

#uuaxumjvmz .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }

#uuaxumjvmz .gt_left { text-align: left; }

#uuaxumjvmz .gt_center { text-align: center; }

#uuaxumjvmz .gt_right { text-align: right; font-variant-numeric: tabular-nums; }

#uuaxumjvmz .gt_font_normal { font-weight: normal; }

#uuaxumjvmz .gt_font_bold { font-weight: bold; }

#uuaxumjvmz .gt_font_italic { font-style: italic; }

#uuaxumjvmz .gt_super { font-size: 65%; }

#uuaxumjvmz .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }

#uuaxumjvmz .gt_asterisk { font-size: 100%; vertical-align: 0; }

#uuaxumjvmz .gt_indent_1 { text-indent: 5px; }

#uuaxumjvmz .gt_indent_2 { text-indent: 10px; }

#uuaxumjvmz .gt_indent_3 { text-indent: 15px; }

#uuaxumjvmz .gt_indent_4 { text-indent: 20px; }

#uuaxumjvmz .gt_indent_5 { text-indent: 25px; } </style>

<tr class="gt_col_headings">
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="Variable">Variable</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="&lt;em&gt;M (SD)&lt;/em&gt;"><em>M (SD)</em></th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="1">1</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="2">2</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="3">3</th>
</tr>
  1. agea

50.61 (18.51)




  1. health

2.26 (0.92)

.28 ***
[0.25, 0.30]



  1. depression

1.67 (0.48)

.03 *
[0.00, 0.05]

.42 ***
[0.40, 0.44]


  1. healthy_eating

4.97 (1.11)

.17 ***
[0.15, 0.19]

-.09 ***
[-0.11, -0.07]

-.13 ***
[-0.15, -0.10]

M and SD are used to represent mean and standard deviation, respectively. Values in square brackets indicate the 95% confidence interval for each correlation.
p < .1, * p < .05, ** p < .01, *** p < .001

#It is often helpful to rename variables in this step #Use get_rename_tribbles(ess_health) to get most of this code var_renames <- tibble::tribble( ~old, ~new,
"agea", "Age",
"health", "Poor health", "depression", "Depression", "healthy_eating", "Healthy eating", )

#A rename tibble or vector automatically only selects the variables included into it ess_health %>% cor_matrix(var_names = var_renames) %>% report_cor_table()

<style>#qvuoajfxcb table { font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

#qvuoajfxcb thead, #qvuoajfxcb tbody, #qvuoajfxcb tfoot, #qvuoajfxcb tr, #qvuoajfxcb td, #qvuoajfxcb th { border-style: none; }

#qvuoajfxcb p { margin: 0; padding: 0; }

#qvuoajfxcb .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }

#qvuoajfxcb .gt_caption { padding-top: 4px; padding-bottom: 4px; }

#qvuoajfxcb .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }

#qvuoajfxcb .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }

#qvuoajfxcb .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }

#qvuoajfxcb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; }

#qvuoajfxcb .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }

#qvuoajfxcb .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }

#qvuoajfxcb .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }

#qvuoajfxcb .gt_column_spanner_outer:first-child { padding-left: 0; }

#qvuoajfxcb .gt_column_spanner_outer:last-child { padding-right: 0; }

#qvuoajfxcb .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }

#qvuoajfxcb .gt_spanner_row { border-bottom-style: hidden; }

#qvuoajfxcb .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }

#qvuoajfxcb .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }

#qvuoajfxcb .gt_from_md > :first-child { margin-top: 0; }

#qvuoajfxcb .gt_from_md > :last-child { margin-bottom: 0; }

#qvuoajfxcb .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: none; border-top-width: 1px; border-top-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }

#qvuoajfxcb .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }

#qvuoajfxcb .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }

#qvuoajfxcb .gt_row_group_first td { border-top-width: 2px; }

#qvuoajfxcb .gt_row_group_first th { border-top-width: 2px; }

#qvuoajfxcb .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }

#qvuoajfxcb .gt_first_summary_row { border-top-style: none; border-top-color: #D3D3D3; }

#qvuoajfxcb .gt_first_summary_row.thick { border-top-width: 2px; }

#qvuoajfxcb .gt_last_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }

#qvuoajfxcb .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }

#qvuoajfxcb .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: none; border-top-width: 6px; border-top-color: #D3D3D3; }

#qvuoajfxcb .gt_last_grand_summary_row_top { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }

#qvuoajfxcb .gt_striped { background-color: rgba(128, 128, 128, 0.05); }

#qvuoajfxcb .gt_table_body { border-top-style: solid; border-top-width: 1px; border-top-color: #000000; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; }

#qvuoajfxcb .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }

#qvuoajfxcb .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }

#qvuoajfxcb .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }

#qvuoajfxcb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }

#qvuoajfxcb .gt_left { text-align: left; }

#qvuoajfxcb .gt_center { text-align: center; }

#qvuoajfxcb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }

#qvuoajfxcb .gt_font_normal { font-weight: normal; }

#qvuoajfxcb .gt_font_bold { font-weight: bold; }

#qvuoajfxcb .gt_font_italic { font-style: italic; }

#qvuoajfxcb .gt_super { font-size: 65%; }

#qvuoajfxcb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }

#qvuoajfxcb .gt_asterisk { font-size: 100%; vertical-align: 0; }

#qvuoajfxcb .gt_indent_1 { text-indent: 5px; }

#qvuoajfxcb .gt_indent_2 { text-indent: 10px; }

#qvuoajfxcb .gt_indent_3 { text-indent: 15px; }

#qvuoajfxcb .gt_indent_4 { text-indent: 20px; }

#qvuoajfxcb .gt_indent_5 { text-indent: 25px; } </style>

<tr class="gt_col_headings">
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="Variable">Variable</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="&lt;em&gt;M (SD)&lt;/em&gt;"><em>M (SD)</em></th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="1">1</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="2">2</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="3">3</th>
</tr>
  1. Age

50.61 (18.51)




  1. Poor health

2.26 (0.92)

.28 ***
[0.25, 0.30]



  1. Depression

1.67 (0.48)

.03 *
[0.00, 0.05]

.42 ***
[0.40, 0.44]


  1. Healthy eating

4.97 (1.11)

.17 ***
[0.15, 0.19]

-.09 ***
[-0.11, -0.07]

-.13 ***
[-0.15, -0.10]

M and SD are used to represent mean and standard deviation, respectively. Values in square brackets indicate the 95% confidence interval for each correlation.
p < .1, * p < .05, ** p < .01, *** p < .001

#Often, it is also interesting to include variable distributions ess_health %>% cor_matrix(var_names = var_renames) %>% report_cor_table(add_distributions = TRUE, data = ess_health)

<style>#actthsbpbh table { font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

#actthsbpbh thead, #actthsbpbh tbody, #actthsbpbh tfoot, #actthsbpbh tr, #actthsbpbh td, #actthsbpbh th { border-style: none; }

#actthsbpbh p { margin: 0; padding: 0; }

#actthsbpbh .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }

#actthsbpbh .gt_caption { padding-top: 4px; padding-bottom: 4px; }

#actthsbpbh .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }

#actthsbpbh .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }

#actthsbpbh .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }

#actthsbpbh .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; }

#actthsbpbh .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }

#actthsbpbh .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }

#actthsbpbh .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }

#actthsbpbh .gt_column_spanner_outer:first-child { padding-left: 0; }

#actthsbpbh .gt_column_spanner_outer:last-child { padding-right: 0; }

#actthsbpbh .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }

#actthsbpbh .gt_spanner_row { border-bottom-style: hidden; }

#actthsbpbh .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }

#actthsbpbh .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }

#actthsbpbh .gt_from_md > :first-child { margin-top: 0; }

#actthsbpbh .gt_from_md > :last-child { margin-bottom: 0; }

#actthsbpbh .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: none; border-top-width: 1px; border-top-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }

#actthsbpbh .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }

#actthsbpbh .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }

#actthsbpbh .gt_row_group_first td { border-top-width: 2px; }

#actthsbpbh .gt_row_group_first th { border-top-width: 2px; }

#actthsbpbh .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }

#actthsbpbh .gt_first_summary_row { border-top-style: none; border-top-color: #D3D3D3; }

#actthsbpbh .gt_first_summary_row.thick { border-top-width: 2px; }

#actthsbpbh .gt_last_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }

#actthsbpbh .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }

#actthsbpbh .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: none; border-top-width: 6px; border-top-color: #D3D3D3; }

#actthsbpbh .gt_last_grand_summary_row_top { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }

#actthsbpbh .gt_striped { background-color: rgba(128, 128, 128, 0.05); }

#actthsbpbh .gt_table_body { border-top-style: solid; border-top-width: 1px; border-top-color: #000000; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; }

#actthsbpbh .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }

#actthsbpbh .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }

#actthsbpbh .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }

#actthsbpbh .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }

#actthsbpbh .gt_left { text-align: left; }

#actthsbpbh .gt_center { text-align: center; }

#actthsbpbh .gt_right { text-align: right; font-variant-numeric: tabular-nums; }

#actthsbpbh .gt_font_normal { font-weight: normal; }

#actthsbpbh .gt_font_bold { font-weight: bold; }

#actthsbpbh .gt_font_italic { font-style: italic; }

#actthsbpbh .gt_super { font-size: 65%; }

#actthsbpbh .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }

#actthsbpbh .gt_asterisk { font-size: 100%; vertical-align: 0; }

#actthsbpbh .gt_indent_1 { text-indent: 5px; }

#actthsbpbh .gt_indent_2 { text-indent: 10px; }

#actthsbpbh .gt_indent_3 { text-indent: 15px; }

#actthsbpbh .gt_indent_4 { text-indent: 20px; }

#actthsbpbh .gt_indent_5 { text-indent: 25px; } </style>

<tr class="gt_col_headings">
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="Variable">Variable</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="&lt;em&gt;M (SD)&lt;/em&gt;"><em>M (SD)</em></th>
  <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="Distributions">Distributions</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="1">1</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="2">2</th>
  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="3">3</th>
</tr>
  1. Age

50.61 (18.51)




  1. Poor health

2.26 (0.92)

.28 ***
[0.25, 0.30]



  1. Depression

1.67 (0.48)

.03 *
[0.00, 0.05]

.42 ***
[0.40, 0.44]


  1. Healthy eating

4.97 (1.11)

.17 ***
[0.15, 0.19]

-.09 ***
[-0.11, -0.07]

-.13 ***
[-0.15, -0.10]

M and SD are used to represent mean and standard deviation, respectively. Values in square brackets indicate the 95% confidence interval for each correlation.
p < .1, * p < .05, ** p < .01, *** p < .001

Describe categorical variables and their relation with an outcome

Often, we are also interested in how the means of an outcome variable differ between different groups. It can be fiddly to get these tables and the pairwise significance tests done, but this function does it in a breeze.

# Start with this in the console - that gets you 80% of the tribbles below.
# get_rename_tribbles(ess_health, gndr, cntry)

var_renames <- tribble(
    ~old,     ~new,     
    "gndr",   "Gender",  
    "cntry",  "Country"
)

level_renames <- tribble(
    ~var,     ~level_old, ~level_new, 
    "gndr",   "1",        "male",       
    "gndr",   "2",        "female",       
    "cntry",  "DE",       "Germany",      
    "cntry",  "FR",       "France",      
    "cntry",  "GB",       "UK"
)

report_cat_vars(ess_health, health, gndr, cntry, var_names = var_renames, 
              level_names = level_renames)
<style>body{background-color:white;}</style>
<style>#ypnxlklxpy table { font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } #ypnxlklxpy thead, #ypnxlklxpy tbody, #ypnxlklxpy tfoot, #ypnxlklxpy tr, #ypnxlklxpy td, #ypnxlklxpy th { border-style: none; } #ypnxlklxpy p { margin: 0; padding: 0; } #ypnxlklxpy .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #ypnxlklxpy .gt_caption { padding-top: 4px; padding-bottom: 4px; } #ypnxlklxpy .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #ypnxlklxpy .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; } #ypnxlklxpy .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ypnxlklxpy .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; } #ypnxlklxpy .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ypnxlklxpy .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #ypnxlklxpy .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #ypnxlklxpy .gt_column_spanner_outer:first-child { padding-left: 0; } #ypnxlklxpy .gt_column_spanner_outer:last-child { padding-right: 0; } #ypnxlklxpy .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #ypnxlklxpy .gt_spanner_row { border-bottom-style: hidden; } #ypnxlklxpy .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; } #ypnxlklxpy .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #ypnxlklxpy .gt_from_md > :first-child { margin-top: 0; } #ypnxlklxpy .gt_from_md > :last-child { margin-bottom: 0; } #ypnxlklxpy .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: none; border-top-width: 1px; border-top-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #ypnxlklxpy .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; } #ypnxlklxpy .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; } #ypnxlklxpy .gt_row_group_first td { border-top-width: 2px; } #ypnxlklxpy .gt_row_group_first th { border-top-width: 2px; } #ypnxlklxpy .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ypnxlklxpy .gt_first_summary_row { border-top-style: none; border-top-color: #D3D3D3; } #ypnxlklxpy .gt_first_summary_row.thick { border-top-width: 2px; } #ypnxlklxpy .gt_last_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ypnxlklxpy .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ypnxlklxpy .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: none; border-top-width: 6px; border-top-color: #D3D3D3; } #ypnxlklxpy .gt_last_grand_summary_row_top { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 6px; border-bottom-color: #D3D3D3; } #ypnxlklxpy .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #ypnxlklxpy .gt_table_body { border-top-style: solid; border-top-width: 1px; border-top-color: #000000; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; } #ypnxlklxpy .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ypnxlklxpy .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #ypnxlklxpy .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ypnxlklxpy .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #ypnxlklxpy .gt_left { text-align: left; } #ypnxlklxpy .gt_center { text-align: center; } #ypnxlklxpy .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #ypnxlklxpy .gt_font_normal { font-weight: normal; } #ypnxlklxpy .gt_font_bold { font-weight: bold; } #ypnxlklxpy .gt_font_italic { font-style: italic; } #ypnxlklxpy .gt_super { font-size: 65%; } #ypnxlklxpy .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; } #ypnxlklxpy .gt_asterisk { font-size: 100%; vertical-align: 0; } #ypnxlklxpy .gt_indent_1 { text-indent: 5px; } #ypnxlklxpy .gt_indent_2 { text-indent: 10px; } #ypnxlklxpy .gt_indent_3 { text-indent: 15px; } #ypnxlklxpy .gt_indent_4 { text-indent: 20px; } #ypnxlklxpy .gt_indent_5 { text-indent: 25px; } </style>
N Share M (SD)
Gender

male

3482

48.2%

2.23 (0.90) a

female

3744

51.8%

2.30 (0.93) b

Country

Germany

3045

42.1%

2.34 (0.88) a

France

1917

26.5%

2.29 (0.89) a

UK

2264

31.3%

2.14 (0.97) b

M and SD are used to represent mean and standard deviation for health for that group, respectively.
Within each variable, the means of groups with different superscripts differ with p \< .05
(p-values were adjusted using the Holm-method.)

Report regression models with standardized coefficients

In psychology, it is often expected that regression models are reported with both unstandardised (B) and standardized (beta) coefficients. This can be fiddly as separate tables will contain too much redundant information. The functions below easily run a model with standardised variables and create a publication-ready table.

ess_health$gndr <- factor(ess_health$gndr)

#Standard lm model
mod1 <- lm(depression ~ agea + gndr + health + cntry, ess_health)

#Model with standardised coefficients

mod2 <- lm_std(depression ~ agea + gndr + health + cntry, ess_health)

report_lm_with_std(mod1, mod2)
<style>body{background-color:white;}</style>
<style>#wetzcqixyw table { font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } #wetzcqixyw thead, #wetzcqixyw tbody, #wetzcqixyw tfoot, #wetzcqixyw tr, #wetzcqixyw td, #wetzcqixyw th { border-style: none; } #wetzcqixyw p { margin: 0; padding: 0; } #wetzcqixyw .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #wetzcqixyw .gt_caption { padding-top: 4px; padding-bottom: 4px; } #wetzcqixyw .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #wetzcqixyw .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; } #wetzcqixyw .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #wetzcqixyw .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; } #wetzcqixyw .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #wetzcqixyw .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #wetzcqixyw .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #wetzcqixyw .gt_column_spanner_outer:first-child { padding-left: 0; } #wetzcqixyw .gt_column_spanner_outer:last-child { padding-right: 0; } #wetzcqixyw .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #wetzcqixyw .gt_spanner_row { border-bottom-style: hidden; } #wetzcqixyw .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; } #wetzcqixyw .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #wetzcqixyw .gt_from_md > :first-child { margin-top: 0; } #wetzcqixyw .gt_from_md > :last-child { margin-bottom: 0; } #wetzcqixyw .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: none; border-top-width: 1px; border-top-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #wetzcqixyw .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; } #wetzcqixyw .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; } #wetzcqixyw .gt_row_group_first td { border-top-width: 2px; } #wetzcqixyw .gt_row_group_first th { border-top-width: 2px; } #wetzcqixyw .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #wetzcqixyw .gt_first_summary_row { border-top-style: none; border-top-color: #D3D3D3; } #wetzcqixyw .gt_first_summary_row.thick { border-top-width: 2px; } #wetzcqixyw .gt_last_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #wetzcqixyw .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #wetzcqixyw .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: none; border-top-width: 6px; border-top-color: #D3D3D3; } #wetzcqixyw .gt_last_grand_summary_row_top { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 6px; border-bottom-color: #D3D3D3; } #wetzcqixyw .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #wetzcqixyw .gt_table_body { border-top-style: solid; border-top-width: 1px; border-top-color: #000000; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; } #wetzcqixyw .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #wetzcqixyw .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #wetzcqixyw .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #wetzcqixyw .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #wetzcqixyw .gt_left { text-align: left; } #wetzcqixyw .gt_center { text-align: center; } #wetzcqixyw .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #wetzcqixyw .gt_font_normal { font-weight: normal; } #wetzcqixyw .gt_font_bold { font-weight: bold; } #wetzcqixyw .gt_font_italic { font-style: italic; } #wetzcqixyw .gt_super { font-size: 65%; } #wetzcqixyw .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; } #wetzcqixyw .gt_asterisk { font-size: 100%; vertical-align: 0; } #wetzcqixyw .gt_indent_1 { text-indent: 5px; } #wetzcqixyw .gt_indent_2 { text-indent: 10px; } #wetzcqixyw .gt_indent_3 { text-indent: 15px; } #wetzcqixyw .gt_indent_4 { text-indent: 20px; } #wetzcqixyw .gt_indent_5 { text-indent: 25px; } </style>
B (SE) β \[95% CI\]

(Intercept)

1.20 (0.02)\*\*\*

-0.14 \[-0.18, -0.10\]

agea

-0.00 (0.00)\*\*\*

-0.10 \[-0.12, -0.08\]

gndr2

0.12 (0.01)\*\*\*

0.24 \[0.20, 0.28\]

health

0.23 (0.01)\*\*\*

0.44 \[0.42, 0.47\]

cntryFR

-0.01 (0.01)   

-0.02 \[-0.08, 0.03\]

cntryGB

0.04 (0.01)\*\* 

0.08 \[0.03, 0.13\]

N 7171
R2 .20
F-tests

F(5, 7165) = 358.25, p \< .001

Given that dummy variables lose their interpretability when standardized (Fox, 2015), β for dummy variables are semi-standardized, indicating the impact of that dummy on the standardized outcome variable.
p \< .1, \* p \< .05, \*\* p \< .01, \*\*\* p \< .001
#Often the coefficients should be renamed - get_coef_rename_tribble(mod1) 
#is the starting point. In that, markdown formatting can be used.

coef_names <- tribble(
  ~old,           ~new,           
   "(Intercept)",  "*(Intercept)*", 
   "agea",         "Age",        
   "gndr2",        "Gender *(female)*",       
   "health",       "Poor health",      
   "cntryFR",      "France *(vs DE)*",     
   "cntryGB",      "UK *(vs DE)*"
)

report_lm_with_std(mod1, mod2, coef_renames = coef_names)
<style>body{background-color:white;}</style>
<style>#qnkfogpjwm table { font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } #qnkfogpjwm thead, #qnkfogpjwm tbody, #qnkfogpjwm tfoot, #qnkfogpjwm tr, #qnkfogpjwm td, #qnkfogpjwm th { border-style: none; } #qnkfogpjwm p { margin: 0; padding: 0; } #qnkfogpjwm .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #qnkfogpjwm .gt_caption { padding-top: 4px; padding-bottom: 4px; } #qnkfogpjwm .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #qnkfogpjwm .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; } #qnkfogpjwm .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #qnkfogpjwm .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; } #qnkfogpjwm .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #qnkfogpjwm .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #qnkfogpjwm .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #qnkfogpjwm .gt_column_spanner_outer:first-child { padding-left: 0; } #qnkfogpjwm .gt_column_spanner_outer:last-child { padding-right: 0; } #qnkfogpjwm .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #qnkfogpjwm .gt_spanner_row { border-bottom-style: hidden; } #qnkfogpjwm .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; } #qnkfogpjwm .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #qnkfogpjwm .gt_from_md > :first-child { margin-top: 0; } #qnkfogpjwm .gt_from_md > :last-child { margin-bottom: 0; } #qnkfogpjwm .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: none; border-top-width: 1px; border-top-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #qnkfogpjwm .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; } #qnkfogpjwm .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; } #qnkfogpjwm .gt_row_group_first td { border-top-width: 2px; } #qnkfogpjwm .gt_row_group_first th { border-top-width: 2px; } #qnkfogpjwm .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #qnkfogpjwm .gt_first_summary_row { border-top-style: none; border-top-color: #D3D3D3; } #qnkfogpjwm .gt_first_summary_row.thick { border-top-width: 2px; } #qnkfogpjwm .gt_last_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #qnkfogpjwm .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #qnkfogpjwm .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: none; border-top-width: 6px; border-top-color: #D3D3D3; } #qnkfogpjwm .gt_last_grand_summary_row_top { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 6px; border-bottom-color: #D3D3D3; } #qnkfogpjwm .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #qnkfogpjwm .gt_table_body { border-top-style: solid; border-top-width: 1px; border-top-color: #000000; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; } #qnkfogpjwm .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #qnkfogpjwm .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #qnkfogpjwm .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #qnkfogpjwm .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #qnkfogpjwm .gt_left { text-align: left; } #qnkfogpjwm .gt_center { text-align: center; } #qnkfogpjwm .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #qnkfogpjwm .gt_font_normal { font-weight: normal; } #qnkfogpjwm .gt_font_bold { font-weight: bold; } #qnkfogpjwm .gt_font_italic { font-style: italic; } #qnkfogpjwm .gt_super { font-size: 65%; } #qnkfogpjwm .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; } #qnkfogpjwm .gt_asterisk { font-size: 100%; vertical-align: 0; } #qnkfogpjwm .gt_indent_1 { text-indent: 5px; } #qnkfogpjwm .gt_indent_2 { text-indent: 10px; } #qnkfogpjwm .gt_indent_3 { text-indent: 15px; } #qnkfogpjwm .gt_indent_4 { text-indent: 20px; } #qnkfogpjwm .gt_indent_5 { text-indent: 25px; } </style>
B (SE) β \[95% CI\]

(Intercept)

1.20 (0.02)\*\*\*

-0.14 \[-0.18, -0.10\]

Age

-0.00 (0.00)\*\*\*

-0.10 \[-0.12, -0.08\]

Gender (female)

0.12 (0.01)\*\*\*

0.24 \[0.20, 0.28\]

Poor health

0.23 (0.01)\*\*\*

0.44 \[0.42, 0.47\]

France (vs DE)

-0.01 (0.01)   

-0.02 \[-0.08, 0.03\]

UK (vs DE)

0.04 (0.01)\*\* 

0.08 \[0.03, 0.13\]

N 7171
R2 .20
F-tests

F(5, 7165) = 358.25, p \< .001

Given that dummy variables lose their interpretability when standardized (Fox, 2015), β for dummy variables are semi-standardized, indicating the impact of that dummy on the standardized outcome variable.
p \< .1, \* p \< .05, \*\* p \< .01, \*\*\* p \< .001
#You can also easily display multiple nested models side-by-side and get the
#F-change significance test. For that, all models need to be fit on the same
#dataset, so that I will drop all missing data.

mod1 <- lm(depression ~ agea + gndr + health + cntry, tidyr::drop_na(ess_health))
mod2 <- lm_std(depression ~ agea + gndr + health + cntry, tidyr::drop_na(ess_health))


mod3 <- lm(depression ~ agea * gndr + eisced + health + cntry, tidyr::drop_na(ess_health))
mod4 <- lm_std(depression ~ agea * gndr + eisced + health + cntry, tidyr::drop_na(ess_health))

coef_names <- tribble(
  ~old,           ~new,           
   "(Intercept)",  "*(Intercept)*", 
   "agea",         "Age",        
   "gndr2",        "Gender *(female)*",       
   "health",       "Poor health",      
   "cntryFR",      "France *(vs DE)*",     
   "cntryGB",      "UK *(vs DE)*",
   "eisced",       "Education",
   "agea:gndr2",   "Age x Female",
)

report_lm_with_std(mod = list(mod1, mod3), mod_std = list(mod2, mod4),
                   coef_renames = coef_names, R2_change = TRUE)
#> Warning: Automatic coercion from double to character was deprecated in purrr 1.0.0.
#> ℹ Please use an explicit call to `as.character()` within `map_chr()` instead.
#> ℹ The deprecated feature was likely used in the timesaveR package.
#>   Please report the issue at
#>   <https://github.com/LukasWallrich/timesaveR/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
<style>body{background-color:white;}</style>
<style>#qfvwbyqenp table { font-family: times, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } #qfvwbyqenp thead, #qfvwbyqenp tbody, #qfvwbyqenp tfoot, #qfvwbyqenp tr, #qfvwbyqenp td, #qfvwbyqenp th { border-style: none; } #qfvwbyqenp p { margin: 0; padding: 0; } #qfvwbyqenp .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: none; background-color: #FFFFFF; width: auto; border-top-style: none; border-top-width: 2px; border-top-color: #FFFFFF; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #qfvwbyqenp .gt_caption { padding-top: 4px; padding-bottom: 4px; } #qfvwbyqenp .gt_title { color: #333333; font-size: 12px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #qfvwbyqenp .gt_subtitle { color: #333333; font-size: 12px; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; } #qfvwbyqenp .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #qfvwbyqenp .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #000000; } #qfvwbyqenp .gt_col_headings { border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #qfvwbyqenp .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #qfvwbyqenp .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #qfvwbyqenp .gt_column_spanner_outer:first-child { padding-left: 0; } #qfvwbyqenp .gt_column_spanner_outer:last-child { padding-right: 0; } #qfvwbyqenp .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #qfvwbyqenp .gt_spanner_row { border-bottom-style: hidden; } #qfvwbyqenp .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; } #qfvwbyqenp .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: none; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #qfvwbyqenp .gt_from_md > :first-child { margin-top: 0; } #qfvwbyqenp .gt_from_md > :last-child { margin-bottom: 0; } #qfvwbyqenp .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: none; border-top-width: 1px; border-top-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #qfvwbyqenp .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; } #qfvwbyqenp .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; } #qfvwbyqenp .gt_row_group_first td { border-top-width: 2px; } #qfvwbyqenp .gt_row_group_first th { border-top-width: 2px; } #qfvwbyqenp .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #qfvwbyqenp .gt_first_summary_row { border-top-style: none; border-top-color: #D3D3D3; } #qfvwbyqenp .gt_first_summary_row.thick { border-top-width: 2px; } #qfvwbyqenp .gt_last_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #qfvwbyqenp .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #qfvwbyqenp .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: none; border-top-width: 6px; border-top-color: #D3D3D3; } #qfvwbyqenp .gt_last_grand_summary_row_top { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-bottom-style: none; border-bottom-width: 6px; border-bottom-color: #D3D3D3; } #qfvwbyqenp .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #qfvwbyqenp .gt_table_body { border-top-style: solid; border-top-width: 1px; border-top-color: #000000; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; } #qfvwbyqenp .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #qfvwbyqenp .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #qfvwbyqenp .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #qfvwbyqenp .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; } #qfvwbyqenp .gt_left { text-align: left; } #qfvwbyqenp .gt_center { text-align: center; } #qfvwbyqenp .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #qfvwbyqenp .gt_font_normal { font-weight: normal; } #qfvwbyqenp .gt_font_bold { font-weight: bold; } #qfvwbyqenp .gt_font_italic { font-style: italic; } #qfvwbyqenp .gt_super { font-size: 65%; } #qfvwbyqenp .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; } #qfvwbyqenp .gt_asterisk { font-size: 100%; vertical-align: 0; } #qfvwbyqenp .gt_indent_1 { text-indent: 5px; } #qfvwbyqenp .gt_indent_2 { text-indent: 10px; } #qfvwbyqenp .gt_indent_3 { text-indent: 15px; } #qfvwbyqenp .gt_indent_4 { text-indent: 20px; } #qfvwbyqenp .gt_indent_5 { text-indent: 25px; } </style>
Model 1 Model 2
B (SE) β \[95% CI\] B (SE) β \[95% CI\]

(Intercept)

1.21 (0.02)\*\*\*

-0.14 \[-0.18, -0.10\]

1.27 (0.02)\*\*\*

-0.14 \[-0.18, -0.10\]

Age

-0.00 (0.00)\*\*\*

-0.10 \[-0.12, -0.08\]

-0.00 (0.00)\*\*\*

-0.14 \[-0.17, -0.10\]

Gender (female)

0.11 (0.01)\*\*\*

0.24 \[0.20, 0.28\]

0.03 (0.03)   

0.24 \[0.20, 0.28\]

Poor health

0.23 (0.01)\*\*\*

0.44 \[0.42, 0.46\]

0.23 (0.01)\*\*\*

0.44 \[0.42, 0.46\]

France (vs DE)

-0.01 (0.01)   

-0.03 \[-0.08, 0.02\]

-0.01 (0.01)   

-0.03 \[-0.08, 0.02\]

UK (vs DE)

0.04 (0.01)\*\* 

0.08 \[0.03, 0.13\]

0.04 (0.01)\*\* 

0.08 \[0.03, 0.13\]

Education

-0.00 (0.00)†  

-0.02 \[-0.04, 0.00\]

Age x Female

0.00 (0.00)\*\* 

0.07 \[0.02, 0.11\]

N 6852 6852
R2 .20 .20
F-tests

F(5, 6846) = 337.06, p \< .001

F(7, 6844) = 243.10, p \< .001

Change ΔR2 = .00, F(2, 6844) = 6.78, p = .001
Given that dummy variables lose their interpretability when standardized (Fox, 2015), β for dummy variables are semi-standardized, indicating the impact of that dummy on the standardized outcome variable.
p \< .1, \* p \< .05, \*\* p \< .01, \*\*\* p \< .001

Related/alternative packages

  • modelsummary allows you to create highly customisable tables with data summaries or the output of statistical models that can be saved in a wide range of formats.
  • apa mostly offers functions that turn the output of statistical tests (e.g., t-tests) into text, in line with APA guidelines.
  • papaja offers the opportunity to create full APA-style journal manuscripts in R. It’s apa_table function is a generic alternative to the table functions in this package, which support many more types of models, but includes fewer details.

timesaver's People

Contributors

lukaswallrich avatar actions-user avatar

Stargazers

Josh Erickson avatar  avatar William Lima avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

pedersebastian

timesaver's Issues

fmt_p returns misleading results with character input

Especially false significant results must be avoided.

library(timesaveR)
#> Note re timesaveR: Many functions in this package are alpha-versions - please treat results with care and report bugs and desired features.
fmt_p("a")
#> [1] "> 1 (!!)"
# and worse
fmt_p(".1")
#> [1] "< .001"

Created on 2024-07-10 with reprex v2.0.2

gt_apa_style: format group headings

Often gt tables benefit from group headings (stubs) - but both in default and in gt_apa_style, they are not clear. Ideally, they should have negative indent and be in italics, in tables like this:

image

Harmonise argument names

Before submitting this to CRAN, argument names should be cleaned up. Particularly, the data argument should always be called data (unless a single vector, then x), and always come first. Also, same argument in related functions should have the same name (items vs scale_items in make_scale(s).

Below the status quo:

Folder Function Arguments
R/cat_desc_table.R .add_css code, class, add
R/cat_desc_table.R report_cat_vars data, dv, ..., var_names, level_names, p_adjust, alpha_level, filename, notes, dv_name, bold_vars, apa_style, css_tags, na.rm, exclude_na
R/cor_tables.R .wtd_cor_test_lm x, y, wt, ...
R/cor_tables.R cor_matrix data, var_names, missing, conf_level, method, adjust, bootstrap, seed
R/cor_tables.R cor_matrix_mi data, weights, var_names
R/cor_tables.R gt_add_plots gt_table, plots, col_index
R/cor_tables.R plot_distributions data, var_names, plot_type, hist_align_y, plot_theme
R/cor_tables.R report_cor_table cor_matrix, ci, n, add_distributions, data, filename, notes, stars, add_title, extras, apa_style, ...
R/cor_tables.R svy_cor_matrix svy_data, var_names, return_n
R/cor_tables.R tidy.cor_matrix x, both_directions, ...
R/cor_tables.R tidy.svy_cor_matrix x, both_directions, ...
R/cor_tables.R wtd_cor_matrix_mi mi_list, weights, var_names
R/formatters.R fmt_ci lower, upper, digits, drop_0
R/formatters.R fmt_cor cor_value, digits
R/formatters.R fmt_p p_value, digits, equal_sign
R/formatters.R fmt_pct x, digits
R/formatters.R round_ x, digits
R/formatters.R round_df df, digits
R/make_scales.R .cronbach_boot list_compl_data, boot
R/make_scales.R .scale_formula items
R/make_scales.R make_scale data, scale_items, scale_name, reverse, reverse_items, two_items_reliability, r_key, proration_cutoff, print_hist, print_desc, return_list, harmonize_ranges
R/make_scales.R make_scale_mi data, scale_items, scale_name, proration_cutoff, seed, alpha_ci, boot, parallel, ...
R/make_scales.R make_scales data, items, reversed, two_items_reliability, print_desc, ...
R/make_scales.R pool_estimates x, ci
R/make_scales.R range_ x, digits, simplify
R/make_scales.R spearman_brown data, items, name, SB_only
R/make_scales.R svy_make_scale data, scale_items, scale_name, print_hist, print_desc, scale_title, reversed, r_key
R/med_mod_code.R run_mediation data, X, Y, Ms, CVs, standardized_all, conf_level, seed, bootstraps, ...
R/med_mod_plots.R .grViz_and_save code, filename
R/med_mod_plots.R plot_mediation IV, DV, Ms, data, digits, coef_offset, filename, ind_p_values
R/med_mod_plots.R plot_moderated_mediation X, M, W, Y, CV, mod_direct_path, labels, filename
R/misc.R .floor_ceiling x, i
R/misc.R .is.numeric_col col, data
R/misc.R .make_stars_note stars, markdown
R/misc.R .pad x, len, padding
R/misc.R .unescape_html str
R/misc.R add_class x, class_to_add
R/misc.R clip_excel data, row_names, col_names, ...
R/misc.R cut_p x, p, ties.method, fct_levels, verbose
R/misc.R dump_to_clip objects
R/misc.R dupl_items x
R/misc.R get_coef_rename_tribble mod, show
R/misc.R get_rename_tribbles data, ..., show, which, max_levels
R/misc.R l2v x, strings, separators, to_clip, return
R/misc.R line_to_vector x, strings, separators, to_clip, return
R/misc.R na_ifs x, replace
R/misc.R na_share x, round
R/misc.R na_when x, ..., operator
R/misc.R named_list ...
R/misc.R paste_ ..., sep, collapse
R/misc.R rename_cat_variables data, var_names, level_names
R/misc.R rm_na x
R/misc.R run_and_format code
R/misc.R scale_blank x, center, scale
R/misc.R sigstars p, stars, pad_html, ns, return_NAs
R/misc.R to_tribble x, show, digits, to_clip
R/mod_tables.R .lm_F_test mod
R/mod_tables.R fmt_labels_md tab, position
R/mod_tables.R glance.mira x, adj_R2, ...
R/mod_tables.R gt_apa_style gt_table, fmt_labels_md
R/mod_tables.R mira.lm_F_test mod, return_list
R/mod_tables.R report_lm_with_std mod, mod_std, conf_level, coef_renames, fmt, statistic_vertical, filename, model_names, show_nimp, R2_change, notes, apa_style, stars, ...
R/mod_tables.R report_polr_with_std mod, mod_std, OR, conf_level, fmt, statistic_vertical, filename, model_names, show_nimp, notes, apa_style, stars, ...
R/mod_tables.R tidy_custom.polr x, ...
R/mod_tables.R tidy.mira x, conf.int, conf.level, ...
R/mod_tables.R tidy.tsR_std x, ...
R/pcor.R pcor_matrix data, given, ...
R/project_management.R add_package_snippets
R/project_management.R ggsave_show filename, ..., device, units
R/project_management.R rproj_to_clip
R/project_management.R setup_analysis_project folder, analyses, pipeline_name, code_folder, standard_packages, github_packages
R/report_stats.R report_anova x
R/stat_tests.R .clean_names x
R/stat_tests.R .run_t_test_mi mi_list
R/stat_tests.R .wtd_t_test_lm dv, g, wt, ...
R/stat_tests.R dummy_code x, prefix, drop_first, verbose
R/stat_tests.R get_pairwise_letters tests, alpha_level, p.adjust.method
R/stat_tests.R lm_std formula, data, weights, ...
R/stat_tests.R paired_t_test_d data, x, y
R/stat_tests.R pairwise_t_test_mi mi_list, dv, groups, weights, p.adjust.method
R/stat_tests.R pairwise_t_tests data, outcome, groups, p.adjust.method, conf_level, var_equal
R/stat_tests.R polr_std formula, data, weights, ...
R/stat_tests.R svy_cohen_d_pair data, dv, iv, pair, ttest, print
R/stat_tests.R svy_pairwise_t_test data, dv, iv, cats, p.adjust, ...
R/stat_tests.R t_test_mi mi_list, dv, groups, weights
R/svy_helpers.R svy_miss_var_summary svy_data, ..., .any_missing, .include_complete
R/timesaveR.R .check_req_packages x, note
R/timesaveR.R .onAttach libname, pkgname
R/timesaveR.R knit_print.timesaveR_raw_html x, ...
R/timesaveR.R print.timesaveR_raw_html x, ...

Singular variables break cor_matrix_mi

The following fails with uninformative error - take check from make_scales() and remove singular variables with warning/message.

 df <- tibble(.imp = rep(1, 10), a = 1:10, b = rep(10, 10))
cor_matrix_mi(df)

pairwise_t_tests - better error with only 1 grou[p

This is not clear

library(tidyverse)
library(timesaveR)
#> Note re timesaveR: Many functions in this package are alpha-versions - please treat results with care and report bugs and desired features.

df <- mtcars %>% filter(cyl == 6)

pairwise_t_tests(df, mpg ~ cyl)
#> Error in utils::combn(., 2): n < m

Created on 2024-05-17 with reprex v2.0.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.