Trying to set up for a McNemar test, but I cannot code very well (using R)
My data is paired, and it is 1000 pairs long, so I have a column specifying the pair number like
c(0 , 0 , 1, 1, 2, 2, 3, 3, 4, 4)
A column specifying which member of the pair is in the control group or treatment (each pair has one of each player, but in a random order) like:
c(0, 1, 1, 0, 1, 0, 0, 1, 0, 1)
And there is a column called response, in which neither, one, or both of the members of the pair could receive a response like:
c(0, 1, 1, 1, 1, 0, 0, 0, 0, 1)
I am trying to create a matrix counting up the results, like:
a <- count of pairs in which both members received a response
b <- count of pairs in which the control only received a response
c <- treatment only response
d <- Neither response
matrix(c(a, b, c, d), 2, 2)
What lines of code could I run to filter my data to get a, b, c, and d? I have been trying to use the tidyverse package, so it could be base R or tidyverse