chisq.test(x, y=NULL, correct=T)
Conversely, if x or y is not a factor/category object (and x is not a matrix), it will be coerced to one implicitly. In this case pairs (x[i],y[i]) containing NAs will be removed, but not pairs with Infs. Coercion of x and y in this manner is intended for datasets of mode numeric, whose elements are typically small integers; data in the form of character vectors should first be made into factor or category objects.
Indiscriminate use of chisq.test with arbitrary count data is to be discouraged. The null hypothesis (i.e., probability model), sampling scheme and sizes of the counts all have bearing on the meaningfulness of the test, and some thought should be given to these.
The degrees of freedom (returned component parameters) are given by the product (R-1)*(C-1), where R is the number of rows and C the number of columns of the contingency table.
Fleiss, J. L. (1981). Statistical Methods for Rates and Proportions, 2nd ed. New York: Wiley.
Snedecor, G. W. and Cochran, W. G. (1980). Statistical Methods, 7th ed. Ames, Iowa: Iowa State University Press.
table(x,y) # x and y are factor objects. No Yes A 13 13 B 20 14 chisq.test(x,y) chisq.test(table(x,y)) # same thing as chisq.test(x,y)