Chi-squared test when two vectors have different lengths I want to compare two groups (vectors) having different lengths to see if their distributions differ considerably. However, when I use chisq.test, I get an error due to inequalities of lengths:
> chisq.test(factor(Group1), factor(Group2))

results in:
Error in chisq.test(factor(Group1[, col]), factor(Group2[, col])) : 
'x' and 'y' must have the same length

Could someone help me with this? Thanks.
 A: I think (as mentioned in comments) that a hypothesis test doesn't really answer the question you say you're interested in. (It also lacks power if any of the factors are ordered).
The thing is, 'not so much different' relates to a question about effect size (how different are they?) not a hypothesis test ("is our sample large enough to pick up even unimportant differences?"). 
You say you have very large sample sizes. This will cause you to reject as different distributions that are quite similar (since you'll have enough power to pick up tiny differences). Is that really what you mean to do? Or would you rather be able to say 'actually, they're fairly similarly distributed' when that's the case?

The direct answer to the question is you use table on the pair of factors you want to test (e.g. Group and race) and then use that as input to chisq.test e.g. 
# make up some data
set.seed(32892917)
mydata <- data.frame(group=as.factor(sample(1:5,199,replace=TRUE)),
                     race=as.factor(sample(1:3,199,replace=TRUE)))

# look at the table:
 (mytab <- with(mydata,table(group,race)) )
     race
group  1  2  3
    1 16 19 11
    2 14 15 13
    3  9 14 20
    4 12 13 11
    5 11 11 10

(you'll note that each group is a different size - e.g. group 1 has 46 people, group 5 has 32)
 # do the chi-square 
 chisq.test(mytab)

    Pearson's Chi-squared test

data:  mytab
X-squared = 6.0928, df = 8, p-value = 0.6368

