I have more like a statistical question... I have a data frame like this:
ID diagnosis Q1 Q2 Q3 Q4
1 x yes A D B B
2 y no B D B A
3 z yes A D C C
4 ad yes <NA> C A C
5 tgfg yes C E <NA> C
6 gfgh no C <NA> A C
7 asj yes D A B D
8 gh no A A D B
9 sdf no B A E <NA>
10 asdgz no D A B A
Here Q1 to Q4 correspond to the questions in my test that I applied to participants(in real data, I have 30 questions). The letters below represent the options they choose. My questions actually have "right" answers. But I also want to analyze whether diagnosed and healthy group differs in their choice of a specific option and whether are there within-group differences across questions in my test. So, I want to analyze this as categorical data.
I first wanted to do multiple chi-squares for each question for diagnosed and undiagnosed groups but it gave an error:
mydf %>%
group_by(diagnosis, Q1) %>%
summarise(count = count(Q1)) %>%
summarise(pvalue= chisq.test(count)$p.value)
Error in `summarise()`:
! Problem while computing `count =
count(Q1)`.
i The error occurred in group 1: diagnosis =
"no", Q1 = "A".
Caused by error in `UseMethod()`:
! no applicable method for 'count' applied to an object of class "character"
Run `rlang::last_error()` to see where the error occurred.
Sorry that I am not clear enough... In short, how can I compare the within and between groups' choices on the options in my test?