friendly / VCDR

Visualizing categorical data with R
0 stars 0 forks source link

vcd returns $\phi$ for non-2x2 tables #29

Closed philchalmers closed 9 years ago

philchalmers commented 9 years ago

This seems to occur in assocstats(), but could occur in other places too. In the call

structure(list(table = x, chisq_tests = tab, phi = phi, contingency = cont, 
        cramer = cramer), class = "assocstats")

for assocstats(), change it to

structure(list(table = x, chisq_tests = tab, phi = ifelse(all(dim(x) == 2L), phi, NA), 
               contingency = cont, cramer = cramer), class = "assocstats")

to return an NA for $\phi$ when the table is not 2x2. Alternatively, only print Cramer's V, and in the case where the table is 2x2 change the print() output label to Phi-Coefficient instead of Cramer's V, because in that case they are equivalent.

davidjohannesmeyer commented 9 years ago

Thanks; fixed in rev. 800.