Column of 0's created in call to r table() function, but there are no 0's in the columns used for the call

116 Views Asked by At

I am slightly new to R, and I am running into a problem. I have a data set that I am working on, and trying to preform a chi squared test on two of columns. However whenever I call the table function in R to make a crosstab to use in the chi squared test it adds a row and column of 0's even though there are no zeros in either of the columns. This is causing my chi squared test to produce a pvalue of nan and I cannot figure out where this extra column and row of zeros is coming from.

copy = ecomm_df[!(is.na(ecomm_df$profile) | is.na(ecomm_df$purchasedBefore)),]

tab = table(copy$profile,copy$purchasedBefore)

chi_test = chisq.test(tab)

chi_test$expected

copy

below is the example of when I call table on the two dataframe columns

output of the table call

where might these extra row and column becoming from?

0

There are 0 best solutions below