How to test to see if one variable is independent of another variable?

I need to know if one variable is independent of another variable. They are both nominal categories. I have tried a t.test, but this occurs:

t.test(role ~ sr_qual, data = dfsleep)
Error in if (stderr < 10 * .Machine$double.eps * max(abs(mx), abs(my))) stop("data are essentially constant") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(x) : argument is not numeric or logical: returning NA
2: In var(x) : NAs introduced by coercion
3: In mean.default(y) : argument is not numeric or logical: returning NA
4: In var(y) : NAs introduced by coercion

I need to know if one variable is independent of another variable. They are both nominal categories. I have tried a t.test, but this occurs:

t.test(role ~ sr_qual, data = dfsleep)
Error in if (stderr < 10 * .Machine$double.eps * max(abs(mx), abs(my))) stop("data are essentially constant") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(x) : argument is not numeric or logical: returning NA
2: In var(x) : NAs introduced by coercion
3: In mean.default(y) : argument is not numeric or logical: returning NA
4: In var(y) : NAs introduced by coercion

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.