Written to support stratified tables to summary_factorlist. See example below for explantion.

colname2label(.data, .cols)

Arguments

.data

Data frame

.cols

Quoted character vector of columns to change

Examples

library(rlang) library(dplyr) explanatory = c("age.factor", "sex.factor") dependent = "perfor.factor" # Pick option below split = "rx.factor" split = c("rx.factor", "node4.factor") # Piped function to generate stratified crosstabs table colon_s %>% group_by(!!! syms(split)) %>% #Looks awkward, but avoids unquoted var names do( summary_factorlist(., dependent, explanatory, total = TRUE, p = TRUE) ) %>% data.frame() %>% dependent_label(colon_s, dependent, prefix = "") %>% colname2label(split)
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Treatment >4 positive nodes Perforation No Yes #> 1 Obs No Age <40 years 14 (100.0) 0 (0.0) #> 2 Obs No 40-59 years 89 (96.7) 3 (3.3) #> 3 Obs No 60+ years 118 (96.7) 4 (3.3) #> 4 Obs No Sex Female 101 (97.1) 3 (2.9) #> 5 Obs No Male 120 (96.8) 4 (3.2) #> 6 Obs Yes Age <40 years 10 (90.9) 1 (9.1) #> 7 Obs Yes 40-59 years 31 (96.9) 1 (3.1) #> 8 Obs Yes 60+ years 44 (100.0) 0 (0.0) #> 9 Obs Yes Sex Female 44 (97.8) 1 (2.2) #> 10 Obs Yes Male 41 (97.6) 1 (2.4) #> 11 Lev No Age <40 years 14 (100.0) 0 (0.0) #> 12 Lev No 40-59 years 78 (96.3) 3 (3.7) #> 13 Lev No 60+ years 123 (97.6) 3 (2.4) #> 14 Lev No Sex Female 89 (97.8) 2 (2.2) #> 15 Lev No Male 126 (96.9) 4 (3.1) #> 16 Lev Yes Age <40 years 4 (80.0) 1 (20.0) #> 17 Lev Yes 40-59 years 33 (97.1) 1 (2.9) #> 18 Lev Yes 60+ years 48 (96.0) 2 (4.0) #> 19 Lev Yes Sex Female 39 (92.9) 3 (7.1) #> 20 Lev Yes Male 46 (97.9) 1 (2.1) #> 21 Lev+5FU No Age <40 years 15 (100.0) 0 (0.0) #> 22 Lev+5FU No 40-59 years 72 (97.3) 2 (2.7) #> 23 Lev+5FU No 60+ years 130 (95.6) 6 (4.4) #> 24 Lev+5FU No Sex Female 115 (96.6) 4 (3.4) #> 25 Lev+5FU No Male 102 (96.2) 4 (3.8) #> 26 Lev+5FU Yes Age <40 years 11 (100.0) <NA> #> 27 Lev+5FU Yes 40-59 years 31 (100.0) <NA> #> 28 Lev+5FU Yes 60+ years 37 (100.0) <NA> #> 29 Lev+5FU Yes Sex Female 44 (100.0) <NA> #> 30 Lev+5FU Yes Male 35 (100.0) <NA> #> Total p #> 1 14 0.790 #> 2 92 #> 3 122 #> 4 104 0.882 #> 5 124 #> 6 11 0.183 #> 7 32 #> 8 44 #> 9 45 0.961 #> 10 42 #> 11 14 0.689 #> 12 81 #> 13 126 #> 14 91 0.692 #> 15 130 #> 16 5 0.221 #> 17 34 #> 18 50 #> 19 42 0.254 #> 20 47 #> 21 15 0.606 #> 22 74 #> 23 136 #> 24 119 0.868 #> 25 106 #> 26 11 NA #> 27 31 #> 28 37 #> 29 44 NA #> 30 35