Reputation: 45
I'm having a data frame as below. I want to run a chi-square test between 'placement' and 'books_quantile' variables at each level of zip codes. I've tried a few ways but not successful yet. Can somebody help?
Thank you!
str(zip2)
tibble [10,748 x 3] (S3: tbl_df/tbl/data.frame)
$ placement : Factor w/ 5 levels "3 or More Grade Levels Below",..: 5 3 3 3 5 2 2 5 3 5 ...
$ books_quantile: Factor w/ 4 levels "Q1 (>=56 books)",..: 2 2 2 2 3 3 3 2 1 2 ...
$ zip : Factor w/ 24 levels "38016","38018",..: 11 21 9 8 22 12 15 15 13 12 ...
Upvotes: 0
Views: 858
Reputation: 79348
You should do:
apply(xtabs(~placement + books_quantile + zip, zip2), 3, chisq.test)
Upvotes: 1