# http://www.danieldsjoberg.com/gtsummary/articles/tbl_summary.html
# Select screening variables
  qn_data_demog = qn_data %>% select(group, sex, sibs, age, wink_ind, PPVT_perc, CPM, T_Self_Report, train_weeks)
# Rename groups
  qn_data_demog$group = dplyr::recode(qn_data_demog$group, 
                         CG = "Controls", TG = "Zirkus Empathico")
# Apply labels
  qn_data_demog = apply_labels(qn_data_demog,
                      sex = "Sex",
                      sibs = "Siblings",
                      age = "Age (years)",
                      wink_ind = "SES (Winkler index)",
                      PPVT_perc = "Verbal age (PPVT percentiles)",
                      CPM = "Nonverbal IQ (CPM)")
  
# Make SES categorical variable
  qn_data_demog$wink_ind = factor(qn_data_demog$wink_ind)
# Prepare table
  demog_table =
    tbl_summary(
      qn_data_demog,
      by = group, # split table by group
      type = c(age, PPVT_perc, CPM) ~ "continuous",
      statistic = list(all_continuous() ~ "{mean} ({sd})", # descriptives definition
                     all_categorical() ~ "{n} / {N} ({p}%)"),
      digits = all_continuous() ~ 2,
      missing = "no" # don't list missing data separately
    ) %>%
    add_n() %>% # add column with total number of non-missing observations
    #add_p() %>% # test for a difference between groups
    modify_header(label = "**Variable**") %>% # update the column header
    bold_labels()
  
# Print table 
  demog_table| Variable | N | Controls, N = 381 | Zirkus Empathico, N = 361 | 
|---|---|---|---|
| Sex | 74 | ||
| Female | 18 / 38 (47%) | 16 / 36 (44%) | |
| Male | 20 / 38 (53%) | 20 / 36 (56%) | |
| Siblings | 74 | ||
| 0 | 4 / 38 (11%) | 7 / 36 (19%) | |
| 1 | 25 / 38 (66%) | 18 / 36 (50%) | |
| 2 | 8 / 38 (21%) | 7 / 36 (19%) | |
| 3 | 1 / 38 (2.6%) | 3 / 36 (8.3%) | |
| 4 | 0 / 38 (0%) | 1 / 36 (2.8%) | |
| Age (years) | 74 | 5.10 (0.90) | 5.12 (0.80) | 
| wink_ind | 74 | ||
| 5 | 1 / 38 (2.6%) | 0 / 36 (0%) | |
| 6 | 0 / 38 (0%) | 1 / 36 (2.8%) | |
| 8 | 2 / 38 (5.3%) | 1 / 36 (2.8%) | |
| 9 | 2 / 38 (5.3%) | 1 / 36 (2.8%) | |
| 10 | 5 / 38 (13%) | 5 / 36 (14%) | |
| 11 | 7 / 38 (18%) | 4 / 36 (11%) | |
| 12 | 5 / 38 (13%) | 7 / 36 (19%) | |
| 13 | 8 / 38 (21%) | 9 / 36 (25%) | |
| 14 | 6 / 38 (16%) | 6 / 36 (17%) | |
| 15 | 2 / 38 (5.3%) | 2 / 36 (5.6%) | |
| Verbal age (PPVT percentiles) | 74 | 68.45 (24.79) | 68.39 (24.95) | 
| Nonverbal IQ (CPM) | 74 | 14.79 (3.73) | 13.92 (3.43) | 
| T_Self_Report | 71 | 323.76 (127.95) | 351.21 (122.52) | 
| train_weeks | 74 | 7.09 (0.90) | 6.98 (1.27) | 
| 
          
            1
          
           
          n / N (%); Mean (SD)
           | |||
Note. SES = socioeconomic status (Winkler & Stolzenberg, 1998, range: 3-15, low SES = 3-6, medium SES = 7-10, high SES = 11-15), PPVT = Peabody Picture Vocabulary Test, CPM = Coloured Progressive Matrices.
tadaa_t.test(data = qn_data, response = T_Self_Report, group = group, print = "markdown")# Get session info
sessionInfo()R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
 [1] tadaatoolbox_0.17.0 miceadds_3.11-6     mice_3.13.0        
 [4] gtsummary_1.4.0     expss_0.10.7        eeptools_1.2.4     
 [7] XLConnect_1.0.3     forcats_0.5.1       stringr_1.4.0      
[10] dplyr_1.0.5         purrr_0.3.4         readr_1.4.0        
[13] tidyr_1.1.3         tibble_3.1.1        ggplot2_3.3.3      
[16] tidyverse_1.3.1     kableExtra_1.3.4   
loaded via a namespace (and not attached):
 [1] minqa_1.2.4         colorspace_2.0-0    rio_0.5.26         
 [4] class_7.3-18        ellipsis_0.3.1      htmlTable_2.1.0    
 [7] base64enc_0.1-3     fs_1.5.0            gld_2.6.2          
[10] proxy_0.4-25        rstudioapi_0.13     mvtnorm_1.1-1      
[13] fansi_0.4.2         lubridate_1.7.10    xml2_1.3.2         
[16] splines_4.0.2       rootSolve_1.8.2.1   knitr_1.32         
[19] pixiedust_0.9.1     Formula_1.2-4       jsonlite_1.7.2     
[22] nloptr_1.2.2.2      gt_0.2.2            rJava_0.9-13       
[25] broom_0.7.6         cluster_2.1.2       dbplyr_2.1.1       
[28] png_0.1-7           compiler_4.0.2      httr_1.4.2         
[31] backports_1.2.1     assertthat_0.2.1    Matrix_1.3-2       
[34] cli_2.4.0           formatR_1.9         htmltools_0.5.1.1  
[37] tools_4.0.2         lmom_2.8            coda_0.19-4        
[40] gtable_0.3.0        glue_1.4.2          Rcpp_1.0.6         
[43] carData_3.0-4       cellranger_1.1.0    jquerylib_0.1.3    
[46] vctrs_0.3.7         svglite_2.0.0       nlme_3.1-152       
[49] broom.helpers_1.3.0 lmtest_0.9-38       xfun_0.22          
[52] openxlsx_4.2.3      lme4_1.1-26         rvest_1.0.0        
[55] lifecycle_1.0.0     statmod_1.4.35      MASS_7.3-53.1      
[58] zoo_1.8-9           scales_1.1.1        hms_1.0.0          
[61] expm_0.999-6        RColorBrewer_1.1-2  curl_4.3           
[64] Exact_2.1           yaml_2.2.1          gridExtra_2.3      
[67] sass_0.3.1          rpart_4.1-15        latticeExtra_0.6-29
[70] stringi_1.5.3       highr_0.9           maptools_1.1-1     
[73] e1071_1.7-6         checkmate_2.0.0     zip_2.1.1          
 [ reached getOption("max.print") -- omitted 45 entries ]