I have a large data frame with many variables. Many are likert scale answers and schools which observations belong to they are logic variables (and can include overlap).
Example:
Q1 <- c(1,2,2,4,3,5)
Q2 <- c(3,4,3,5,4,5)
A <- c(TRUE,FALSE,TRUE,TRUE,FALSE,TRUE)
B <- c(FALSE,TRUE,FALSE,TRUE,FALSE,FALSE)
df <- data.frame(Q1,Q2, A, B)
The output I want is a contingency table :
Q1
1 2 3 4 5
A 1 1 0 1 1
B 0 1 0 1 0
where I can do a chi2
test between schools - here A
and B
. Nothing I have tried works.
I think there maybe answer in what I have read online but I lack the knowledge to recognize it!