Hello everyone, I am very new at R programming and I am having a particular issue creating a contingency table in the way that I want. I need to run fisher.test and I cannot get the table to work. I have two categorical variables tmt (a,d) and postneg (yes, no). However, the values that I need for this table are in a different column named (score).Table with variables and values. I tried grouping the variables (tmt, postneg) and summarize adding the values of (score).
summary_cramp_data <- cramp_data %>% group_by(tmt,postneg) %>% summarise(sum_score=sum(score))
Then I tried creating a tibble table
contingency <- summary_cramp_data %>% pivot_wider(names_from = postneg, values_from = sum_score)
*The table looks like this: Tibble table
Finally I transformed the table to a matrix
as.matrix(contingency)
However when running fisher test I keep having this error:
> fisher.test(contingency)
Error in fisher.test(contingency) :
all entries of 'x' must be nonnegative and finite
I would really appreciate if anyone can help me with this issue. Thank you very much, Danisa