Print chi square statistic with table in R

Viewed 188

My dataset looks like this (with about 200+ variables):

intervention<-c(1,1,2,2,3,3)
age_group<-c("17-24 years","25-55 years","17-24 years","17-24 years","25-55 years", "25-55 years")
gender<-c("male","male","female","female","male","female")
marital_status<-c("partnered","single","single","partnered","partnered","single")
education<-c("high school","university","university","university","high school","university")
df<-data.frame(intervention,age_group,gender,marital_status,education)

I used the tableone package to put this into a table stratified by intervention:

listVar_Int<-c("age_group","gender","marital_status","education")
catVar_Int<-c("intervention", "age_group","gender","marital_status","education")
Table_int<-CreateTableOne(vars = listVar_Int, data = df, factorVars = catVar_Int, strata = c("intervention"))

When I print it (print(Table_int, nonnormal = biomarkers, exact = "stage", quote = TRUE, noSpaces = TRUE, showAllLevels = TRUE) ), the table looks like this (table from my actual dataset):

                                      Stratified by Intervention group
                                          1           2           3           p test    
n                                         127         122         125              
age_group (%)                                                                 0.713
 17-24 years                             42 (33.3)   33 (27.7)   39 (31.5)  
 25-55 years                             60 (47.6)   60 (50.4)   67 (54.0)                  
gender (%)                                                                    0.047
 Male                                     49 (38.9)   59 (49.2)   71 (57.7)  
 Female                                   54 (42.9)   43 (35.8)   34 (27.6)  

Based on what I've read, the default test is the chisq.test. Is there a way to print the chi square test statistic so that it shows up alongside the p test?

0 Answers
Related