Skip to content
Prev 268964 / 398502 Next

Chi square test on data frame

If your data is d1:

temp <- apply(d1[,1:4], 1, order, decreasing=TRUE)[1:2,]
temp <- rbind(temp, temp+4)
result <- sapply(1:nrow(d1), function(i)
     chisq.test(matrix(as.matrix(d1[i,temp[,i]]), ncol=2)))

Uwe Ligges
On 16.08.2011 23:26, Bansal, Vikas wrote: