Reputation: 1
I am looking to perform chi-squared on three different vectors which have an unequal sample size.
I have tried to do this as both vectors and combing the data in a dataframe but continue to get error messages including "x" and "y" must have the same length.
I have put some example vectors below / how I have combined into dataframe.
alpha <- c(10,15,20)
bravo <- c(12,18,19,20)
charlie <-c(19,30,21,34,10)
> chisq.test(alpha, bravo, charlie)
Error in chisq.test(alpha, bravo, charlie) :
'x' and 'y' must have the same length
max_ln1 <- max(c(length(alpha), length(bravo)))
max_ln2 <- max(c(length(charlie)))
max_ln<-max(max_ln2,max_ln1)
df_fem<- data.frame(total = c(alpha,rep(NA, max_ln - length(alpha))),
af = c(bravo,rep(NA, max_ln - length(bravo))),
naive = c(charlie,rep(NA, max_ln - length(charlie))))
Upvotes: 0
Views: 77