I have this data.frame:
df <- data.frame(xy = c("x", "y"), V1 = c(3, 0), V2 = c(0, 0), V3 = c(5, 0), V4 = c(5, 2))
df
xy V1 V2 V3 V4
1 x 3 0 5 5
2 y 0 0 0 2
I want to know if x
or y
is more associated with any of V1
, V2
, V3
or V4
. To test this, I can use a chi-squared.
This is what I've tried, none of which work:
chisq.test(df)
chisq.test(as.matrix(df))
chisq.test(as.table(df))
How can I run a chi-squared test on df
?