Reputation: 173
I have the following table:
Word | Cat | Num |
---|---|---|
shiwu | DE | 214 |
shiwu | N | 190 |
dongxi | DE | 1308 |
dongxi | N | 925 |
How do I run chisq.test to test if the DE/N ratio of shiwu (214/190) is significantly different from the DE/N ratio of dongxi (1308/925)?
Upvotes: 0
Views: 65
Reputation: 860
I think this code could be useful.
tibble(Word = c("shiwu", "shiwu", "dongxi", "dongxi"),
Cat = c("DE", "N", "DE", "N"),
Num = c(214, 190, 1308, 925)) %>% # build tibble (like data frame)
pivot_wider(names_from = Cat, values_from = Num) %>% # structuring it as a table
column_to_rownames("Word") %>% # defining first column (Word) as rownames
as.matrix() %>% # converting data for a contigency table
chisq.test() # executing chi-squared test
The answer will be a result of Pearson Chi-squared test with Yates correction (this correction, for this data will not influence the result).
Pearson's Chi-squared test with Yates' continuity correction
data: .
X-squared = 4.1782, df = 1, p-value = 0.04095
Good job
Upvotes: 1